ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2025-06-28 08:50:40
Exec Total Coverage
Lines: 9298 12841 72.4%
Functions: 111 141 78.7%
Branches: 7002 11935 58.7%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 #include "base/misctypes.h"
46 #include "base/initdata.h"
47
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern void setZScriptVersion(int32_t s_version);
50
51 static bool read_ext_zinfo = false, read_zinfo = false;
52 static bool loadquest_report = false;
53 static char const* loading_qst_name = NULL;
54 static std::string last_loaded_qstpath;
55 static byte loading_qst_num = 0;
56 static byte subscr_mode = ssdtMAX;
57 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
58 // what combos were used. This vector just lets us convert those old quests on load.
59 static std::vector<byte> old_combo_pages;
60
61 dword loading_tileset_flags = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 extern tiledata *newtilebuf;
81 extern byte *trashbuf;
82 extern itemdata *itemsbuf;
83 extern wpndata *wpnsbuf;
84 extern comboclass *combo_class_buf;
85 extern guydata *guysbuf;
86 extern ZCHEATS zcheats;
87 extern char palnames[MAXLEVELS][17];
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 416 std::map<int32_t, script_slot_data > ffcmap;
92 416 std::map<int32_t, script_slot_data > globalmap;
93 416 std::map<int32_t, script_slot_data > genericmap;
94 416 std::map<int32_t, script_slot_data > itemmap;
95 416 std::map<int32_t, script_slot_data > npcmap;
96 416 std::map<int32_t, script_slot_data > ewpnmap;
97 416 std::map<int32_t, script_slot_data > lwpnmap;
98 416 std::map<int32_t, script_slot_data > playermap;
99 416 std::map<int32_t, script_slot_data > dmapmap;
100 416 std::map<int32_t, script_slot_data > screenmap;
101 416 std::map<int32_t, script_slot_data > itemspritemap;
102 416 std::map<int32_t, script_slot_data > comboscriptmap;
103 416 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 // Each section had a separate, secondary versioning number, but it was never really utilized for
111 // its intended purpose so it's been removed. But we still write something in this field.
112 232 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
113 {
114 232 return p_iputw(section_version, f);
115 }
116
117 14256 bool read_deprecated_section_cversion(PACKFILE* f)
118 {
119 word unused;
120 14256 return p_igetw(&unused, f);
121 }
122
123 21985 void script_slot_data::update()
124 {
125
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 21979 times.
21985 switch (format)
126 {
127 case SCRIPT_FORMAT_INVALID:
128 6 output = fmt::format("{} --{}", slotname, scriptname);
129 6 break;
130 21979 case SCRIPT_FORMAT_DEFAULT:
131 default:
132 21979 output = fmt::format("{} {}", slotname, scriptname);
133 21979 }
134 21985 }
135
136 char qstdat_string[2048] = { 0 };
137
138 static zinfo* load_tmp_zi = NULL;
139
140 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
141 const byte clavio[9]={97,109,111,110,103,117,115,0};
142
143 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
144 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
145
146 const char *qst_error[] =
147 {
148 "OK","File not found","Invalid quest file",
149 "Version not supported","Obsolete version",
150 "Missing new data" , /* but let it pass in ZQuest */
151 "Internal error occurred", "Invalid password",
152 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
153 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
154 };
155
156 //for legacy quests -DD
157 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
158 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
159 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
160 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
161 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
162 };
163
164 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
165
166
167 char *byte_conversion(int32_t number, int32_t format)
168 {
169 static char num_str[40];
170
171 if(format==-1) //auto
172 {
173 format=1; //bytes
174
175 if(number>1024)
176 {
177 format=2; //kilobytes
178 }
179
180 if(number>1024*1024)
181 {
182 format=3; //megabytes
183 }
184
185 if(number>1024*1024*1024)
186 {
187 format=4; //gigabytes (dude, what are you doing?)
188 }
189 }
190
191 switch(format)
192 {
193 case 1: //bytes
194 sprintf(num_str,"%db",number);
195 break;
196
197 case 2: //kilobytes
198 sprintf(num_str,"%.2fk",float(number)/1024);
199 break;
200
201 case 3: //megabytes
202 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
203 break;
204
205 case 4: //gigabytes
206 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
207 break;
208
209 default:
210 abort();
211 break;
212 }
213
214 return num_str;
215 }
216
217 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
218 {
219 static char num_str1[40];
220 static char num_str2[40];
221 static char num_str[80];
222
223 if(format1==-1) //auto
224 {
225 format1=1; //bytes
226
227 if(number1>1024)
228 {
229 format1=2; //kilobytes
230 }
231
232 if(number1>1024*1024)
233 {
234 format1=3; //megabytes
235 }
236
237 if(number1>1024*1024*1024)
238 {
239 format1=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 if(format2==-1) //auto
244 {
245 format2=1; //bytes
246
247 if(number2>1024)
248 {
249 format2=2; //kilobytes
250 }
251
252 if(number2>1024*1024)
253 {
254 format2=3; //megabytes
255 }
256
257 if(number2>1024*1024*1024)
258 {
259 format2=4; //gigabytes (dude, what are you doing?)
260 }
261 }
262
263 switch(format1)
264 {
265 case 1: //bytes
266 sprintf(num_str1,"%db",number1);
267 break;
268
269 case 2: //kilobytes
270 sprintf(num_str1,"%.2fk",float(number1)/1024);
271 break;
272
273 case 3: //megabytes
274 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
275 break;
276
277 case 4: //gigabytes
278 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
279 break;
280
281 default:
282 abort();
283 break;
284 }
285
286 switch(format2)
287 {
288 case 1: //bytes
289 sprintf(num_str2,"%db",number2);
290 break;
291
292 case 2: //kilobytes
293 sprintf(num_str2,"%.2fk",float(number2)/1024);
294 break;
295
296 case 3: //megabytes
297 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
298 break;
299
300 case 4: //gigabytes
301 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
302 break;
303
304 default:
305 abort();
306 break;
307 }
308
309 sprintf(num_str, "%s/%s", num_str1, num_str2);
310 return num_str;
311 }
312
313 char *ordinal(int32_t num)
314 {
315 static const char *ending[4] = {"st","nd","rd","th"};
316 static char ord_str[8];
317
318 char *end;
319 int32_t t=(num%100)/10;
320 int32_t n=num%10;
321
322 if(n>=1 && n<4 && t!=1)
323 end = (char *)ending[n-1];
324 else
325 end = (char *)ending[3];
326
327 sprintf(ord_str,"%d%s",num%10000,end);
328 return ord_str;
329 }
330
331 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
332 {
333 int32_t ret;
334 *version=0;
335 *build=0;
336 byte temp_map_count=map_count;
337 byte temp_midi_flags[MIDIFLAGS_SIZE];
338 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
339
340 zquestheader tempheader{};
341
342 if(!f)
343 {
344 return qe_invalid;
345 }
346
347 ret=readheader(f, &tempheader);
348
349 if(ret)
350 {
351 return ret;
352 }
353
354 map_count=temp_map_count;
355 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
356 *version=tempheader.zelda_version;
357 *build=tempheader.build;
358 return 0;
359 }
360
361
362 bool find_section(PACKFILE *f, int32_t section_id_requested)
363 {
364
365 if(!f)
366 {
367 return false;
368 }
369
370 int32_t section_id_read;
371 bool catchup=false;
372 word dummy;
373 byte tempbyte;
374 char tempbuf[65536];
375
376
377 switch(section_id_requested)
378 {
379 case ID_RULES:
380 case ID_STRINGS:
381 case ID_MISC:
382 case ID_TILES:
383 case ID_COMBOS:
384 case ID_CSETS:
385 case ID_MAPS:
386 case ID_DMAPS:
387 case ID_DOORS:
388 case ID_ITEMS:
389 case ID_WEAPONS:
390 case ID_COLORS:
391 case ID_ICONS:
392 case ID_INITDATA:
393 case ID_GUYS:
394 case ID_MIDIS:
395 case ID_CHEATS:
396 break;
397
398 default:
399 al_trace("Bad section requested!\n");
400 return false;
401 break;
402 }
403
404 dword section_size;
405
406 //section id
407 if(!p_mgetl(&section_id_read,f))
408 {
409 return false;
410 }
411
412 while(!pack_feof(f))
413 {
414 switch(section_id_read)
415 {
416 case ID_RULES:
417 case ID_STRINGS:
418 case ID_MISC:
419 case ID_TILES:
420 case ID_COMBOS:
421 case ID_CSETS:
422 case ID_MAPS:
423 case ID_DMAPS:
424 case ID_DOORS:
425 case ID_ITEMS:
426 case ID_WEAPONS:
427 case ID_COLORS:
428 case ID_ICONS:
429 case ID_INITDATA:
430 case ID_GUYS:
431 case ID_MIDIS:
432 case ID_CHEATS:
433 catchup=false;
434 break;
435
436 default:
437 break;
438 }
439
440
441 while(catchup)
442 {
443 //section id
444 section_id_read=(section_id_read<<8);
445
446 if(!p_getc(&tempbyte,f))
447 {
448 return false;
449 }
450
451 section_id_read+=tempbyte;
452 }
453
454 if(section_id_read==section_id_requested)
455 {
456 return true;
457 }
458 else
459 {
460 //section version info
461 if(!p_igetw(&dummy,f))
462 {
463 return false;
464 }
465
466 if(!p_igetw(&dummy,f))
467 {
468 return false;
469 }
470
471 //section size
472 if(!p_igetl(&section_size,f))
473 {
474 return false;
475 }
476
477 //pack_fseek(f, section_size);
478 while(section_size>65535)
479 {
480 pfread(tempbuf,65535,f);
481 tempbuf[65535]=0;
482 section_size-=65535;
483 }
484
485 if(section_size>0)
486 {
487 pfread(tempbuf,section_size,f);
488 tempbuf[section_size]=0;
489 }
490 }
491
492 //section id
493 if(!p_mgetl(&section_id_read,f))
494 {
495 return false;
496 }
497 }
498
499 return false;
500 }
501
502
503
504
505
506 bool valid_zqt(PACKFILE *f)
507 {
508
509 //word tiles_used;
510 //word combos_used;
511 //open the file
512 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
513 if(!f)
514 return false;
515
516 //for now, everything else is valid
517 return true;
518
519 /*int16_t version;
520 byte build;
521
522 //read the version and make sure it worked
523 if(!p_igetw(&version,f))
524 {
525 goto error;
526 }
527
528 //read the build and make sure it worked
529 if(!p_getc(&build,f))
530 goto error;
531
532 //read the tile info and make sure it worked
533 if(!p_igetw(&tiles_used,f))
534 {
535 goto error;
536 }
537
538 for (int32_t i=0; i<tiles_used; i++)
539 {
540 if(!pfread(trashbuf,tilesize(tf4Bit),f))
541 {
542 goto error;
543 }
544 }
545
546 //read the combo info and make sure it worked
547 if(!p_igetw(&combos_used,f))
548 {
549 goto error;
550 }
551 for (int32_t i=0; i<combos_used; i++)
552 {
553 if(!pfread(trashbuf,sizeof(newcombo),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the palette info and make sure it worked
560 for (int32_t i=0; i<48; i++)
561 {
562 if(!pfread(trashbuf,newpdTOTAL,f))
563 {
564 goto error;
565 }
566 }
567 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
568 {
569 goto error;
570 }
571 for (int32_t i=0; i<MAXLEVELS; i++)
572 {
573 if(!pfread(trashbuf,PALNAMESIZE,f))
574 {
575 goto error;
576 }
577 }
578
579 //read the sprite info and make sure it worked
580 for (int32_t i=0; i<MAXITEMS; i++)
581 {
582 if(!pfread(trashbuf,sizeof(itemdata),f))
583 {
584 goto error;
585 }
586 }
587
588 for (int32_t i=0; i<MAXWPNS; i++)
589 {
590 if(!pfread(trashbuf,sizeof(wpndata),f))
591 {
592 goto error;
593 }
594 }
595
596 //read the triforce pieces info and make sure it worked
597 for (int32_t i=0; i<8; ++i)
598 {
599 if(!p_getc(&trashbuf,f))
600 {
601 goto error;
602 }
603 }
604
605
606
607 //read the game icons info and make sure it worked
608 for (int32_t i=0; i<4; ++i)
609 {
610 if(!p_igetw(&trashbuf,f))
611 {
612 goto error;
613 }
614 }
615
616 //read the misc colors info and map styles info and make sure it worked
617 if(!pfread(trashbuf,sizeof(zcolors),f))
618 {
619 goto error;
620 }
621
622 //read the template screens and make sure it worked
623 byte num_maps;
624 if(!p_getc(&num_maps,f))
625 {
626 goto error;
627 }
628 for (int32_t i=0; i<TEMPLATES; i++)
629 {
630 if(!pfread(trashbuf,sizeof(mapscr),f))
631 {
632 goto error;
633 }
634 }
635 if (num_maps>1) //dungeon templates
636 {
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f))
640 {
641 goto error;
642 }
643 }
644 }
645
646 //yay! it worked! close the file and say everything was ok.
647 pack_fclose(f);
648 return true;
649
650 error:
651 pack_fclose(f);
652 return false;*/
653 }
654
655 bool valid_zqt(const char *filename)
656 {
657 PACKFILE *f=NULL;
658 bool isvalid;
659 int32_t error;
660 f=open_quest_file(&error, filename, false);
661
662 if(!f)
663 {
664 // setPackfilePassword(NULL);
665 return false;
666 }
667
668 isvalid=valid_zqt(f);
669
670 clear_quest_tmpfile();
671 pack_fclose(f);
672
673 // setPackfilePassword(NULL);
674 return isvalid;
675 }
676
677 /*
678 .qst file history
679
680 .qst files have always been compressed using allegro's packfiles.
681
682 At some point, an encoding layer was added. The two layers look like this:
683
684 1) The top layer is from us. See decode_file_007.
685 [0-24] Preamble "Zelda Classic Quest File"
686 [25-28] Initial decoding seed value.
687 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
688 [last 4] Checksum
689
690 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
691 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
692 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
693 The oldest quests skip the password part.
694
695 Simply, the job of this function is to peel away the top layer.
696
697 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
698 in opening and saving files. There is no version field, so they decryption key is
699 found via trial-by-error (very slow!)
700
701 There are other file types of interest:
702 - .zqt: quest template files, skips top-layer encryption pass
703 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
704 - .qu?: same as above. automated backup files
705 - .qb?: same as above. automated backup files
706 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
707
708 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
709 files are now "slh!.AG ZC Enhanced Quest File".
710 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
711 */
712 787 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
713 {
714
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if (show_progress)
715 {
716 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
717 }
718
719 787 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
720
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 482 times.
787 if (unencrypted_result.decoded_pf)
721 305 return unencrypted_result.decoded_pf;
722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 if (unencrypted_result.not_found)
723 {
724 *open_error = qe_notfound;
725 return nullptr;
726 }
727
728 // Everything below here is legacy code - recently saved quest files will have
729 // returned by now.
730 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
731
732 // Note: although this is primarily for loading .qst files, it can also handle all of the
733 // file types mentioned in the comment above. No need to be told if the file being loaded
734 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
735 482 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
736 482 bool compressed = unencrypted_result.compressed;
737 482 bool encrypted = unencrypted_result.encrypted;
738
739 char tmpfilename[L_tmpnam];
740 482 temp_name(tmpfilename);
741 char percent_done[30];
742 482 int32_t current_method=0;
743
744 PACKFILE *f;
745 482 const char *passwd= encrypted ? datapwd : "";
746
747 // oldquest flag is set when an unencrypted qst file is suspected.
748 482 bool oldquest = false;
749 int32_t ret;
750
751
1/2
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
482 if(strcmp(filename, "default.qst")!=0)
752 {
753 482 box_out(filename);
754 482 }
755 else
756 {
757 box_out("new quest"); // Or whatever
758 }
759 482 box_out("...");
760 482 box_eol();
761 482 box_eol();
762
763
1/2
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
482 if(encrypted)
764 {
765 482 box_out("Decrypting...");
766 482 box_save_x();
767 482 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
768
769
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 63 times.
482 if(ret)
770 {
771
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
772 {
773 case 1:
774 box_out("error.");
775 box_eol();
776 box_end(true);
777 *open_error=qe_notfound;
778 return NULL;
779
780 case 2:
781 box_out("error.");
782 box_eol();
783 box_end(true);
784 *open_error=qe_internal;
785 return NULL;
786 // be sure not to delete tmpfilename now...
787 }
788
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
790 {
791 63 current_method++;
792 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
793 63 box_out(percent_done);
794 63 box_load_x();
795 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
796 63 }
797
798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
799 {
800 63 current_method++;
801 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
802 63 box_out(percent_done);
803 63 box_load_x();
804 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
805 63 }
806
807
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
808 {
809 18 current_method++;
810 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
811 18 box_out(percent_done);
812 18 box_load_x();
813 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
814 18 }
815
816
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
817 {
818 12 current_method++;
819 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
820 12 box_out(percent_done);
821 12 box_load_x();
822 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
823 12 }
824
825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
826 {
827 oldquest = true;
828 passwd="";
829 }
830 63 }
831
832 482 box_out("okay.");
833 482 box_eol();
834 482 }
835 else
836 {
837 oldquest = true;
838 }
839
840 482 box_out("Opening...");
841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
842
1/2
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
482 if(!f)
843 {
844 if((compressed==1)&&(errno==EDOM))
845 {
846 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
847 }
848
849 if(!f)
850 {
851 if(!oldquest)
852 {
853 delete_file(tmpfilename);
854 }
855 box_out("error.");
856 box_eol();
857 box_end(true);
858 *open_error=qe_invalid;
859 return NULL;
860 }
861 }
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 if(!oldquest)
864 {
865 482 delete_file(tmpfilename);
866 482 }
867
868 482 box_out("okay.");
869 482 box_eol();
870
871 482 return f;
872 787 }
873
874 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
875 {
876 PACKFILE *f=NULL;
877 int32_t open_error=0;
878
879 if (Header->templatepath[0] != 0)
880 {
881 // TODO: should be safe to remove this, no one seems to use custom quest templates.
882 filename=Header->templatepath;
883 }
884
885 f=open_quest_file(&open_error, filename, false);
886
887 if(!f)
888 {
889 return NULL;
890 }
891
892 if(validate)
893 {
894 if(!valid_zqt(f))
895 {
896 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
897 pack_fclose(f);
898 clear_quest_tmpfile();
899 return NULL;
900 }
901 }
902
903 return f;
904 }
905
906 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
907 {
908 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
909 if (get_app_id() == App::zelda)
910 assert(section_id == ID_TILES);
911
912 combosread=false;
913 mapsread=false;
914 fixffcs=false;
915
916 switch(section_id)
917 {
918 case ID_RULES:
919 case ID_STRINGS:
920 case ID_MISC:
921 case ID_TILES:
922 case ID_COMBOS:
923 case ID_CSETS:
924 case ID_MAPS:
925 case ID_DMAPS:
926 case ID_DOORS:
927 case ID_ITEMS:
928 case ID_WEAPONS:
929 case ID_COLORS:
930 case ID_ICONS:
931 case ID_INITDATA:
932 case ID_GUYS:
933 case ID_MIDIS:
934 case ID_CHEATS:
935 case ID_ITEMDROPSETS:
936 case ID_FAVORITES:
937 break;
938
939 default:
940 return false;
941 break;
942 }
943
944 int32_t ret;
945 word version, build;
946 PACKFILE *f=NULL;
947
948 //why is this here?
949 /*
950 if(colordata==NULL)
951 return false;
952 */
953
954 //setPackfilePassword(datapwd);
955 f=open_quest_template(Header, filename, validate);
956
957 if(!f) //no file, nothing to delete
958 {
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963 ret=get_version_and_build(f, &version, &build);
964
965 if(ret||(version==0))
966 {
967 pack_fclose(f);
968 clear_quest_tmpfile();
969
970 // setPackfilePassword(NULL);
971 return false;
972 }
973
974 if(!find_section(f, section_id))
975 {
976 al_trace("Can't find section!\n");
977 pack_fclose(f);
978 clear_quest_tmpfile();
979
980 //setPackfilePassword(NULL);
981 return false;
982 }
983
984 switch(section_id)
985 {
986 case ID_RULES:
987 //rules
988 ret=readrules(f, Header);
989 break;
990
991 case ID_STRINGS:
992 //strings
993 ret=readstrings(f, Header);
994 break;
995
996 case ID_MISC:
997 //misc data
998 ret=readmisc(f, Header, Misc);
999 break;
1000
1001 case ID_TILES:
1002 //tiles
1003 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1004 break;
1005
1006 case ID_COMBOS:
1007 //combos
1008 clear_combos();
1009 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1010 combosread=true;
1011 break;
1012
1013 case ID_COMBOALIASES:
1014 //combos
1015 ret=readcomboaliases(f, Header, version, build);
1016 break;
1017
1018 case ID_CSETS:
1019 //color data
1020 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1021 break;
1022
1023 case ID_MAPS:
1024 //maps
1025 ret=readmaps(f, Header);
1026 mapsread=true;
1027 break;
1028
1029 case ID_DMAPS:
1030 //dmaps
1031 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1032 break;
1033
1034 case ID_DOORS:
1035 //door combo sets
1036 ret=readdoorcombosets(f, Header);
1037 break;
1038
1039 case ID_ITEMS:
1040 //items
1041 ret=readitems(f, version, build);
1042 break;
1043
1044 case ID_WEAPONS:
1045 //weapons
1046 ret=readweapons(f, Header);
1047 break;
1048
1049 case ID_COLORS:
1050 //misc. colors
1051 ret=readmisccolors(f, Header, Misc);
1052 break;
1053
1054 case ID_ICONS:
1055 //game icons
1056 ret=readgameicons(f, Header, Misc);
1057 break;
1058
1059 case ID_INITDATA:
1060 //initialization data
1061 ret=readinitdata(f, Header);
1062 break;
1063
1064 case ID_GUYS:
1065 //guys
1066 ret=readguys(f, Header);
1067 break;
1068
1069 case ID_MIDIS:
1070 //midis
1071 ret=readtunes(f, Header, tunes);
1072 break;
1073
1074 case ID_CHEATS:
1075 //cheat codes
1076 ret=readcheatcodes(f, Header);
1077 break;
1078
1079 case ID_ITEMDROPSETS:
1080 //item drop sets
1081 // Why is this one commented out?
1082 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1083 break;
1084
1085 case ID_FAVORITES:
1086 // favorite combos and aliases
1087 ret=readfavorites(f, version);
1088 break;
1089
1090 default:
1091 ret=-1;
1092 break;
1093 }
1094
1095 pack_fclose(f);
1096 clear_quest_tmpfile();
1097
1098 //setPackfilePassword(NULL);
1099 if(!ret)
1100 {
1101 return true;
1102 }
1103
1104 return false;
1105 }
1106
1107 bool init_tiles_for_190(bool validate, zquestheader *Header)
1108 {
1109 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1110 }
1111
1112 bool init_tiles(bool validate, zquestheader *Header)
1113 {
1114 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1115 }
1116
1117 bool init_combos(bool validate, zquestheader *Header)
1118 {
1119 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1120 }
1121
1122 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1123 {
1124 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1125 }
1126
1127 787 void init_spritelists()
1128 {
1129
2/2
✓ Branch 0 taken 605 times.
✓ Branch 1 taken 182 times.
787 if(FFCore.quest_format[vZelda] < 0x255)
1130 {
1131 605 guys.setMax(255);
1132 605 items.setMax(255);
1133 605 Ewpns.setMax(255);
1134 605 Lwpns.setMax(255);
1135 605 chainlinks.setMax(255);
1136 605 decorations.setMax(255);
1137 605 particles.setMax(255);
1138 605 }
1139 else
1140 {
1141 182 guys.setMax(255);
1142 182 items.setMax(255);
1143 182 Ewpns.setMax(255);
1144 182 Lwpns.setMax(255);
1145 182 chainlinks.setMax(255);
1146 182 decorations.setMax(255);
1147 182 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1148 }
1149 787 }
1150
1151 309 bool reset_items(bool validate, zquestheader *Header)
1152 {
1153 309 bool ret = true;
1154
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if (get_app_id() == App::zquest)
1155 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1156
1157
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 79104 times.
79413 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 309 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = true;
1172 if (get_app_id() == App::zquest)
1173 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1174
1175 for(int32_t i=0; i<MAXWPNS; i++)
1176 reset_weaponname(i);
1177
1178 return ret;
1179 }
1180
1181 bool reset_mapstyles(bool validate, miscQdata *Misc)
1182 {
1183 Misc->colors.blueframe_tile = 20044;
1184 Misc->colors.blueframe_cset = 0;
1185 Misc->colors.triforce_tile = 23461;
1186 Misc->colors.triforce_cset = 1;
1187 Misc->colors.triframe_tile = 18752;
1188 Misc->colors.triframe_cset = 1;
1189 Misc->colors.overworld_map_tile = 16990;
1190 Misc->colors.overworld_map_cset = 2;
1191 Misc->colors.HCpieces_tile = 21160;
1192 Misc->colors.HCpieces_cset = 8;
1193 Misc->colors.dungeon_map_tile = 19651;
1194 Misc->colors.dungeon_map_cset = 8;
1195 return true;
1196 }
1197
1198 365 int32_t get_qst_buffers()
1199 {
1200 365 TheMaps.resize(MAPSCRS);
1201 365 old_combo_pages.resize(MAPSCRS);
1202 365 map_autolayers.resize(6);
1203
1204 365 Z_message("OK\n");
1205
1206 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1207 // (Shoelace's "Hero of Dreams" uses 1415.)
1208 // So let's be a bit generous and allow 4096 initially.
1209 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1210 // I tested it and it worked without flaw on 6/6/11. - L.
1211 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1212 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1213 // See https://discord.com/channels/876899628556091432/992984989073416242
1214 365 msg_strings_size = 8192;
1215
1216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 365 times.
365 MsgStrings = new MsgStr[msg_strings_size];
1217
1218 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1219
2/2
✓ Branch 0 taken 2990080 times.
✓ Branch 1 taken 365 times.
2990445 for(auto q = 0; q < msg_strings_size; ++q)
1220 {
1221 2990080 MsgStrings[q].clear();
1222 2990080 }
1223
1224
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((DMaps=new dmap[MAXDMAPS])==NULL)
1225 return 0;
1226
1227
1228
1229 365 combobuf.clear();
1230 365 combobuf.resize(MAXCOMBOS);
1231
1232
1233
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1234 return 0;
1235
1236 365 free_newtilebuf();
1237
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1238 return 0;
1239
1240 365 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1241 //Z_message("Performed memset on tiles\n");
1242 365 clear_tiles(newtilebuf);
1243 //Z_message("Performed clear_tiles()\n");
1244
1245
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 13 times.
365 if (get_app_id() == App::zquest)
1246 {
1247
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1248 return 0;
1249
1250 13 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1251 13 clear_tiles(grabtilebuf);
1252 13 }
1253
1254
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((trashbuf=(byte*)malloc(100000))==NULL)
1255 return 0;
1256
1257 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1258 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1259 // fixed by ensuring there's actually itemdata there.
1260 // If you change this, be sure to update del_qst_buffers, too.
1261
1262
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1263 return 0;
1264
1265 365 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1266 365 itemsbuf++;
1267
1268
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1269 return 0;
1270
1271 365 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1272
1273
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1274 return 0;
1275
1276 365 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1277
1278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 365 times.
365 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1279 return 0;
1280
1281 365 return 1;
1282 365 }
1283
1284
1285 685 void free_newtilebuf()
1286 {
1287
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 364 times.
685 if(newtilebuf)
1288 {
1289
2/2
✓ Branch 0 taken 68854500 times.
✓ Branch 1 taken 321 times.
68854821 for(int32_t i=0; i<NEWMAXTILES; i++)
1290
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 68640000 times.
137494500 if(newtilebuf[i].data)
1291 68640000 free(newtilebuf[i].data);
1292
1293 321 free(newtilebuf);
1294 321 newtilebuf = 0;
1295 321 }
1296 685 }
1297
1298 320 void free_grabtilebuf()
1299 {
1300
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 11 times.
320 if (get_app_id() == App::zquest)
1301 {
1302
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1303 {
1304
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1306
1307 11 free(grabtilebuf);
1308 11 grabtilebuf = 0;
1309 11 }
1310 11 }
1311 320 }
1312
1313 320 void del_qst_buffers()
1314 {
1315
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
320 if(MsgStrings) delete[] MsgStrings;
1316
1317
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
320 if (DMaps) delete[] DMaps;
1318
1319 320 combobuf.clear();
1320
1321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(colordata) free(colordata);
1322
1323 320 free_newtilebuf();
1324 320 free_grabtilebuf();
1325
1326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(trashbuf) free(trashbuf);
1327
1328 // See get_qst_buffers
1329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(itemsbuf)
1330 {
1331 320 itemsbuf--;
1332 320 free(itemsbuf);
1333 320 }
1334
1335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(wpnsbuf) free(wpnsbuf);
1336
1337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(guysbuf) free(guysbuf);
1338
1339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(combo_class_buf) free(combo_class_buf);
1340 320 }
1341
1342 18 bool init_palnames()
1343 {
1344 // if(palnames==NULL)
1345 // return false;
1346
1347
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1348 {
1349
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1350 {
1351 case 0:
1352 18 sprintf(palnames[x],"Overworld");
1353 18 break;
1354
1355 case 10:
1356 18 sprintf(palnames[x],"Caves");
1357 18 break;
1358
1359 case 11:
1360 18 sprintf(palnames[x],"Passageways");
1361 18 break;
1362
1363 default:
1364 9162 sprintf(palnames[x],"%c",0);
1365 9162 break;
1366 }
1367 9216 }
1368
1369 18 return true;
1370 }
1371
1372 100088 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1373 {
1374 void *p;
1375
1376
1/2
✓ Branch 0 taken 100088 times.
✗ Branch 1 not taken.
100088 p = _AL_MALLOC(MAX(size, alloc_size));
1377
1378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100088 times.
100088 if(!p)
1379 {
1380 return NULL;
1381 }
1382
1383
1/2
✓ Branch 0 taken 100088 times.
✗ Branch 1 not taken.
100088 if(!pfread(p,size,f))
1384 {
1385 _AL_FREE(p);
1386 return NULL;
1387 }
1388
1389
1/2
✓ Branch 0 taken 100088 times.
✗ Branch 1 not taken.
100088 if(pack_ferror(f))
1390 {
1391 _AL_FREE(p);
1392 return NULL;
1393 }
1394
1395 100088 return p;
1396 100088 }
1397
1398 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1399 static const byte* legacy_skip_flags;
1400
1401 /* read_midi:
1402 * Reads MIDI data from a datafile (this is not the same thing as the
1403 * standard midi file format).
1404 */
1405
1406 10242 static MIDI *read_midi(PACKFILE *f)
1407 {
1408 MIDI *m;
1409 int32_t c;
1410 10242 int16_t divisions=0;
1411 10242 int32_t len=0;
1412
1413 10242 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1414
1415
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!m)
1416 {
1417 return NULL;
1418 }
1419
1420
2/2
✓ Branch 0 taken 327744 times.
✓ Branch 1 taken 10242 times.
337986 for(c=0; c<MIDI_TRACKS; c++)
1421 {
1422 327744 m->track[c].len = 0;
1423 327744 m->track[c].data = NULL;
1424 327744 }
1425
1426 10242 p_mgetw(&divisions,f);
1427 10242 m->divisions=divisions;
1428
1429
2/2
✓ Branch 0 taken 327744 times.
✓ Branch 1 taken 10242 times.
337986 for(c=0; c<MIDI_TRACKS; c++)
1430 {
1431 327744 p_mgetl(&len,f);
1432 327744 m->track[c].len=len;
1433
1434
2/2
✓ Branch 0 taken 227656 times.
✓ Branch 1 taken 100088 times.
327744 if(m->track[c].len > 0)
1435 {
1436 100088 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1437
1438
1/2
✓ Branch 0 taken 100088 times.
✗ Branch 1 not taken.
100088 if(!m->track[c].data)
1439 {
1440 destroy_midi(m);
1441 return NULL;
1442 }
1443 100088 }
1444 327744 }
1445
1446 LOCK_DATA(m, sizeof(MIDI));
1447
1448
2/2
✓ Branch 0 taken 327744 times.
✓ Branch 1 taken 10242 times.
337986 for(c=0; c<MIDI_TRACKS; c++)
1449 {
1450
2/2
✓ Branch 0 taken 100088 times.
✓ Branch 1 taken 227656 times.
327744 if(m->track[c].data)
1451 {
1452 LOCK_DATA(m->track[c].data, m->track[c].len);
1453 100088 }
1454 327744 }
1455
1456 10242 return m;
1457 10242 }
1458
1459 void clear_combo(int32_t i)
1460 {
1461 combobuf[i].clear();
1462 }
1463
1464 void clear_combos()
1465 {
1466 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1467 clear_combo(tmpcounter);
1468 }
1469
1470 void pack_combos()
1471 {
1472 int32_t di = 0;
1473
1474 for(int32_t si=0; si<1024; si+=2)
1475 combobuf[di++] = combobuf[si];
1476
1477 for(; di<1024; di++)
1478 clear_combo(di);
1479 }
1480
1481 469 void reset_tunes(zctune *tune)
1482 {
1483
2/2
✓ Branch 0 taken 118188 times.
✓ Branch 1 taken 469 times.
118657 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1484 {
1485 118188 tune[i].reset();
1486 118188 }
1487 469 }
1488
1489 int32_t doortranslations_u[9][4]=
1490 {
1491 {37,38,53,54},
1492 {37,38,39,40},
1493 {37,38,55,56},
1494 {37,38,39,40},
1495 {37,38,53,54},
1496 {37,38,53,54},
1497 {37,38,53,54},
1498 {7,8,23,24},
1499 {7,8,41,42}
1500 };
1501
1502 int32_t doortranslations_d[9][4]=
1503 {
1504 {117,118,133,134},
1505 {135,136,133,134},
1506 {119,120,133,134},
1507 {135,136,133,134},
1508 {117,118,133,134},
1509 {117,118,133,134},
1510 {117,118,133,134},
1511 {151,152,167,168},
1512 {137,138,167,168},
1513 };
1514
1515 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1516 int32_t doortranslations_l[9][6]=
1517 {
1518 {66,67,82,83,98,99},
1519 {66,68,82,84,98,100},
1520 {66,69,82,85,98,101},
1521 {66,68,82,84,98,100},
1522 {66,67,82,83,98,99},
1523 {66,67,82,83,98,99},
1524 {66,67,82,83,98,99},
1525 {64,65,80,81,96,97},
1526 {64,65,80,114,96,97},
1527 };
1528
1529 int32_t doortranslations_r[9][6]=
1530 {
1531
1532 {76,77,92,93,108,109},
1533 {75,77,91,93,107,109},
1534 {74,77,90,93,106,109},
1535 {75,77,91,93,107,109},
1536 {76,77,92,93,108,109},
1537 {76,77,92,93,108,109},
1538 {76,77,92,93,108,109},
1539 {78,79,94,95,110,111},
1540 {78,79,125,95,110,111},
1541 };
1542
1543 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1544 {
1545 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1546 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1547 }
1548
1549 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1550 {
1551 //these are here to bypass compiler warnings about unused arguments
1552 840750 map=map;
1553 840750 scr=scr;
1554 840750 pos=pos;
1555
1556 //what does this function do?
1557 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1558 840750 return 2;
1559 }
1560
1561 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1562 {
1563
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1564 {
1565 18423 return 0;
1566 }
1567
1568 4425 DoorComboSet tempdcs{};
1569
1570 //up
1571
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1572 {
1573
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1574 {
1575 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1576 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1577 159300 }
1578 39825 }
1579
1580 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1581 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1582 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1583 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1584 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1585 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1586
1587 //down
1588
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1589 {
1590
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1591 {
1592 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1593 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1594 159300 }
1595 39825 }
1596
1597 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1598
1599 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1600 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1601 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1602 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1603 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1604
1605 //left
1606 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1607
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1608 {
1609
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1610 {
1611 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1612 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1613 238950 }
1614 39825 }
1615
1616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1617 {
1618 if((j!=2)&&(j!=3))
1619 {
1620 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1621 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1622 }
1623 }
1624
1625 4425 tempdcs.bombdoorcombo_l[0]=0;
1626 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1627 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1628 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1629 4425 tempdcs.bombdoorcombo_l[2]=0;
1630 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1631 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1632 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1633
1634 //right
1635
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1636 {
1637
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1638 {
1639 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1640 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1641 238950 }
1642 39825 }
1643
1644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1645 {
1646 if((j!=2)&&(j!=3))
1647 {
1648 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1649 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1650 }
1651 }
1652
1653 4425 tempdcs.bombdoorcombo_r[0]=0;
1654 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1655 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1656 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1657 4425 tempdcs.bombdoorcombo_r[2]=0;
1658 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1659 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1660 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1661
1662 int32_t k;
1663
1664
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1665 {
1666
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1667 {
1668 4365 break;
1669 }
1670 5941 }
1671
1672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1673 {
1674 return 0;
1675 }
1676
1677
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1678 {
1679 60 DoorComboSets[k]=tempdcs;
1680 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1681 60 ++door_combo_set_count;
1682 60 }
1683
1684 4425 return k;
1685 /*
1686 doorcombo_u[9][4];
1687 doorcset_u[9][4];
1688 doorcombo_d[9][4];
1689 doorcset_d[9][4];
1690 doorcombo_l[9][6];
1691 doorcset_l[9][6];
1692 doorcombo_r[9][6];
1693 doorcset_r[9][6];
1694 bombdoorcombo_u[2];
1695 bombdoorcset_u[2];
1696 bombdoorcombo_d[2];
1697 bombdoorcset_d[2];
1698 bombdoorcombo_l[3];
1699 bombdoorcset_l[3];
1700 bombdoorcombo_r[3];
1701 bombdoorcset_r[3];
1702 walkthroughcombo[4];
1703 walkthroughcset[4];
1704 */
1705 22848 }
1706
1707 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1708 {
1709 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1710 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1711 }
1712
1713 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1714 {
1715
1716 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1717 }
1718
1719 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1720 {
1721 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1722 }
1723
1724
1725 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1726 {
1727 char temp_pwd[30];
1728 83 memset(temp_pwd,0,30);
1729
1730
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1731 {
1732 75 memcpy(temp_pwd,encrypted_pwd,30);
1733 75 temp_pwd[29]=0;
1734
1735
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1736 {
1737 2250 temp_pwd[i] -= pwdkey;
1738 2250 int32_t t=pwdkey>>15;
1739 2250 pwdkey = (pwdkey<<1)+t;
1740 2250 }
1741 75 }
1742
1743 83 memcpy(pwd,temp_pwd,30);
1744 83 }
1745
1746
1747 256 bool devpwd()
1748 {
1749 #ifdef _DEBUG
1750 return true;
1751 #endif
1752 #if DEVLEVEL > 3
1753 return true;
1754 #endif
1755
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1756 }
1757 bool check_questpwd(zquestheader *Header, char *pwd)
1758 {
1759 if(devpwd())
1760 return true;
1761 if((!strcmp(pwd, (char*)clavio)))
1762 return true;
1763 cvs_MD5Context ctx;
1764 uint8_t md5sum[16];
1765
1766 cvs_MD5Init(&ctx);
1767 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1768 cvs_MD5Final(md5sum, &ctx);
1769
1770 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1771 }
1772
1773 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1774 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1775 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1776
1777 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1778 {
1779 char keyfilename[2048];
1780 replace_extension(keyfilename, path, ext, 2047);
1781 if(!exists(keyfilename))
1782 return false;
1783 bool ret = false;
1784
1785 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1786 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1787 char msg[80] = {0};
1788 pfread(msg, 80, fp);
1789 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1790 {
1791 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1792 pack_fclose(fp);
1793 return false;
1794 }
1795 int16_t ver;
1796 byte bld;
1797 p_igetw(&ver, fp);
1798 p_getc(&bld, fp);
1799 pfread(password, QSTPWD_LEN, fp, true);
1800 if(hashed)
1801 {
1802 char unhashed_pw[QSTPWD_LEN] = {0};
1803
1804 char hashmap = 'Z';
1805 hashmap += 'Q';
1806 hashmap += 'U';
1807 hashmap += 'E';
1808 hashmap += 'S';
1809 hashmap += 'T';
1810
1811 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1812 unhashed_pw[q] = password[q] - hashmap;
1813
1814 ret = check_questpwd(Header, unhashed_pw);
1815 }
1816 else ret = check_questpwd(Header, password);
1817 pack_fclose(fp);
1818 zprint2("Found %s Key File '%s' (%s access)\n",
1819 typestr, keyfilename, ret ? "valid" : "invalid");
1820 return ret;
1821 }
1822
1823 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1824 {
1825 char exedir[PATH_MAX] = {0};
1826 extract_name(path, exedir, FILENAMEALL);
1827 char const* paths[] = {path, exedir};
1828 for(uint keyty : types)
1829 {
1830 if(keyty >= KEYFILE_NUMTY)
1831 continue;
1832 for(char const* p : paths)
1833 {
1834 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1835 return true;
1836 }
1837 }
1838 return false;
1839 }
1840
1841 427 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1842 {
1843 427 zprint2("\n");
1844 427 zprint2("[QUEST METADATA]\n");
1845
1/2
✓ Branch 0 taken 427 times.
✗ Branch 1 not taken.
427 if(path)
1846 427 zprint2("Path: %s\n", path);
1847
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 100 times.
427 if(tempheader.title[0])
1848 327 zprint2("Title: %s\n", tempheader.title);
1849 427 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1850
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 258 times.
427 if(tempheader.new_version_id_date_day)
1851 169 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1852
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 181 times.
427 if(tempheader.version[0])
1853 246 zprint2("Qst Version: %s\n", tempheader.version);
1854
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 100 times.
427 if(tempheader.author[0])
1855 327 zprint2("Author: %s\n", tempheader.author);
1856 427 zprint2("\n");
1857 427 }
1858
1859 799 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1860 {
1861 int32_t dummy;
1862 799 zquestheader tempheader{};
1863
2/2
✓ Branch 0 taken 787 times.
✓ Branch 1 taken 12 times.
799 tempheader.filename = Header->filename;
1864 char dummybuf[80];
1865 byte temp_map_count;
1866 byte temp_midi_flags[MIDIFLAGS_SIZE];
1867 word version;
1868 char temp_pwd[30], temp_pwd2[30];
1869 int16_t temp_pwdkey;
1870 cvs_MD5Context ctx;
1871 787 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
1872 787 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1873
1874
1875
1876
2/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 787 times.
787 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1877 {
1878 Z_message("Unable to read header string\n");
1879 return qe_invalid;
1880 }
1881
1882 // check header
1883
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 24 times.
787 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1884 {
1885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1886 {
1887 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1888 return qe_invalid;
1889 }
1890 24 }
1891
1892 787 int32_t templatepath_len=0;
1893
1894 787 tempheader.external_zinfo = false;
1895 787 read_zinfo = false;
1896
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1897 {
1898 byte padding;
1899
1900
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1901 {
1902 return qe_invalid;
1903 }
1904
1905
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1906 {
1907 return qe_invalid;
1908 }
1909
1910 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1911
1912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1913 {
1914 return qe_version;
1915 }
1916
1917 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1918
1919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1920 {
1921 return qe_invalid;
1922 }
1923
1924
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
1925 {
1926 return qe_obsolete;
1927 }
1928
1929
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_igetw(&tempheader.internal,f))
1930 {
1931 return qe_invalid;
1932 }
1933
1934
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.quest_number,f))
1935 {
1936 return qe_invalid;
1937 }
1938
1939 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
1940
1941
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
1942 {
1943 return qe_invalid;
1944 }
1945
1946
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
1947 {
1948 return qe_invalid;
1949 }
1950
1951 24 FFCore.quest_format[qMapCount] = temp_map_count;
1952
1953
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
1954 {
1955 return qe_invalid;
1956 }
1957
1958
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
1959 {
1960 return qe_invalid;
1961 }
1962
1963
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!pfread(temp_midi_flags,4,f))
1964 {
1965 return qe_invalid;
1966 }
1967
1968
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
1969 {
1970 return qe_invalid;
1971 }
1972
1973
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
1974 {
1975 return qe_invalid;
1976 }
1977
1978
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
1979 {
1980 return qe_invalid;
1981 }
1982
1983
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
1984 {
1985 return qe_invalid;
1986 }
1987
1988
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
1989 {
1990 return qe_invalid;
1991 }
1992
1993
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
1994 {
1995 return qe_invalid;
1996 }
1997 // These fields are expected to end in null bytes!
1998 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
1999
2000
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2001 {
2002 return qe_invalid;
2003 }
2004 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2005
2006
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2007 {
2008 return qe_invalid;
2009 }
2010
2011
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2012 {
2013 return qe_invalid;
2014 }
2015
2016
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2017 {
2018 return qe_invalid;
2019 }
2020
2021 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2022
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2023
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2024
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2025
2026
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2027 {
2028 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2029 // Not anymore...
2030 memset(tempheader.minver,0,17);
2031 tempheader.build=0;
2032 tempheader.use_keyfile=0;
2033 memset(tempheader.old_foo, 0, 9);
2034 }
2035 else
2036 {
2037
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2038 {
2039 return qe_invalid;
2040 }
2041
2042
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2043 {
2044 return qe_invalid;
2045 }
2046
2047 24 FFCore.quest_format[vBuild] = tempheader.build;
2048
2049
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2050 {
2051 return qe_invalid;
2052 }
2053
2054
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2055 {
2056 return qe_invalid;
2057 }
2058 } // starting at minver
2059
2060
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2061 {
2062 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2063 6 }
2064 else
2065 {
2066
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2067 {
2068 return qe_invalid; // starting at rules3
2069 }
2070
2071
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2072 {
2073
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2074 12 }
2075 }
2076
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2077
2078
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2079
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2080 {
2081
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2082
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2083
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2084 18 }
2085
2086
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2087 {
2088 6 byte *mf=temp_midi_flags;
2089
2090
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2091 {
2092 4 mf=(byte*)dummybuf;
2093 4 }
2094
2095
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2096 {
2097 return qe_invalid; // starting at foo2
2098 }
2099
2100
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2101 {
2102 return qe_invalid; // starting at foo2
2103 }
2104 6 }
2105
2106
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2107
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2108 {
2109 18 memset(tempheader.templatepath,0,2048);
2110 18 }
2111 else
2112 {
2113 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2114 {
2115 return qe_invalid;
2116 }
2117 }
2118
2119
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2120
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2121 {
2122 24 tempheader.use_keyfile=0;
2123 24 }
2124 24 }
2125 else
2126 {
2127 //section id
2128
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_mgetl(&dummy,f))
2129 {
2130 return qe_invalid;
2131 }
2132
2133 //section version info
2134
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_igetw(&version,f))
2135 {
2136 return qe_invalid;
2137 }
2138
2139 763 FFCore.quest_format[vHeader] = version;
2140
2141
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_igetw(&dummy,f))
2142 {
2143 return qe_invalid;
2144 }
2145
2146 //section size
2147
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_igetl(&dummy,f))
2148 {
2149 return qe_invalid;
2150 }
2151
2152 //finally... section data
2153
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_igetw(&tempheader.zelda_version,f))
2154 {
2155 return qe_invalid;
2156 }
2157
2158 763 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2159
2160 //do some quick checking...
2161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if(tempheader.zelda_version > ZELDA_VERSION)
2162 {
2163 return qe_version;
2164 }
2165
2166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2167 {
2168 return qe_invalid;
2169 }
2170
2171
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 763 times.
763 if(bad_version(tempheader.zelda_version))
2172 {
2173 return qe_obsolete;
2174 }
2175
2176
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempheader.build,f))
2177 {
2178 return qe_invalid;
2179 }
2180
2181 763 FFCore.quest_format[vBuild] = tempheader.build;
2182
2183
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 704 times.
763 if(version<3)
2184 {
2185
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2186 {
2187 return qe_invalid;
2188 }
2189
2190
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2191 {
2192 return qe_invalid;
2193 }
2194
2195 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2196
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2197
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2198
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2199 59 }
2200 else
2201 {
2202
2/4
✓ Branch 0 taken 704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 704 times.
704 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2203 {
2204 return qe_invalid;
2205 }
2206 }
2207
2208
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_igetw(&tempheader.internal,f))
2209 {
2210 return qe_invalid;
2211 }
2212
2213
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempheader.quest_number,f))
2214 {
2215 return qe_invalid;
2216 }
2217
2218 763 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2219
2220 763 size_t versz = version < 8 ? 9 : 16;
2221
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(tempheader.version,versz,f))
2222 {
2223 return qe_invalid;
2224 }
2225
2226 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2227 //needs to be copied as char[9] or stored as a s.str
2228
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(tempheader.minver,versz,f))
2229 {
2230 return qe_invalid;
2231 }
2232
2233 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2234
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2235 {
2236 return qe_invalid;
2237 }
2238 763 tempheader.title[sizeof(tempheader.title)-1] = 0;
2239
2240
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2241 {
2242 return qe_invalid;
2243 }
2244 763 tempheader.author[sizeof(tempheader.author)-1] = 0;
2245
2246
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempheader.use_keyfile,f))
2247 {
2248 return qe_invalid;
2249 }
2250
2251 /*
2252 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2253 {
2254 return qe_invalid;
2255 }
2256 */
2257
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2258 {
2259 return qe_invalid;
2260 }
2261
2262
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(&dummybuf,4,f))
2263 {
2264 return qe_invalid;
2265 }
2266
2267
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2268 {
2269 return qe_invalid;
2270 }
2271
2272
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(dummybuf,14,f))
2273 {
2274 return qe_invalid;
2275 }
2276
2277 763 templatepath_len=sizeof(tempheader.templatepath);
2278
2279
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 59 times.
763 if(version==1)
2280 {
2281 59 templatepath_len=280;
2282 59 }
2283
2284
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(tempheader.templatepath,templatepath_len,f))
2285 {
2286 return qe_invalid;
2287 }
2288
2289
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&temp_map_count,f))
2290 {
2291 return qe_invalid;
2292 }
2293
2294
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 581 times.
763 if(version>=4)
2295 {
2296
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.version_major,f))
2297 {
2298 return qe_invalid;
2299 }
2300
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.version_minor,f))
2301 {
2302 return qe_invalid;
2303 }
2304
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.version_patch,f))
2305 {
2306 return qe_invalid;
2307 }
2308
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2309 {
2310 return qe_invalid;
2311 }
2312
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2313 {
2314 return qe_invalid;
2315 }
2316
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.new_version_id_beta,f))
2317 {
2318 return qe_invalid;
2319 }
2320
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2321 {
2322 return qe_invalid;
2323 }
2324
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.new_version_id_release,f))
2325 {
2326 return qe_invalid;
2327 }
2328
2329 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2330
3/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
182 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2331 tempheader.version_minor = 55;
2332
2333
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2334 {
2335 return qe_invalid;
2336 }
2337
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&tempheader.new_version_id_date_month,f))
2338 {
2339 return qe_invalid;
2340 }
2341
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&tempheader.new_version_id_date_day,f))
2342 {
2343 return qe_invalid;
2344 }
2345
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2346 {
2347 return qe_invalid;
2348 }
2349
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2350 {
2351 return qe_invalid;
2352 }
2353
2354
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(tempheader.new_version_devsig,256,f))
2355 {
2356 return qe_invalid;
2357 }
2358
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2359 strcpy(tempheader.new_version_devsig, "EmilyV99");
2360
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(tempheader.new_version_compilername,256,f))
2361 {
2362 return qe_invalid;
2363 }
2364
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(tempheader.new_version_compilerversion,256,f))
2365 {
2366 return qe_invalid;
2367 }
2368
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(tempheader.product_name,1024,f))
2369 {
2370 return qe_invalid;
2371 }
2372
2373
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&tempheader.compilerid,f))
2374 {
2375 return qe_invalid;
2376 }
2377
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2378 {
2379 return qe_invalid;
2380 }
2381
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2382 {
2383 return qe_invalid;
2384 }
2385
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2386 {
2387 return qe_invalid;
2388 }
2389
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2390 {
2391 return qe_invalid;
2392 }
2393
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetw(&tempheader.developerid,f))
2394 {
2395 return qe_invalid;
2396 }
2397
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
182 if(!pfread(tempheader.made_in_module_name,1024,f))
2398 {
2399 return qe_invalid;
2400 }
2401
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
182 if(!pfread(tempheader.build_datestamp,256,f))
2402 {
2403 return qe_invalid;
2404 }
2405
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
182 if(!pfread(tempheader.build_timestamp,256,f))
2406 {
2407 return qe_invalid;
2408 }
2409 182 }
2410 else // <4
2411 {
2412 581 tempheader.version_major = 0;
2413 581 tempheader.version_minor = 0;
2414 581 tempheader.version_patch = 0;
2415 581 tempheader.new_version_id_fourth = 0;
2416 581 tempheader.new_version_id_alpha = 0;
2417 581 tempheader.new_version_id_beta = 0;
2418 581 tempheader.new_version_id_gamma = 0;
2419 581 tempheader.new_version_id_release = 0;
2420 581 tempheader.new_version_id_date_year = 0;
2421 581 tempheader.new_version_id_date_month = 0;
2422 581 tempheader.new_version_id_date_day = 0;
2423 581 tempheader.new_version_id_date_hour = 0;
2424 581 tempheader.new_version_id_date_minute = 0;
2425
2426 581 memset(tempheader.new_version_devsig, 0, 256);
2427 581 memset(tempheader.new_version_compilername, 0, 256);
2428 581 memset(tempheader.new_version_compilerversion, 0, 256);
2429 581 memset(tempheader.product_name, 0, 1024);
2430 581 strcpy(tempheader.product_name, "ZQuest Classic");
2431
2432 581 tempheader.compilerid = 0;
2433 581 tempheader.compilerversionnumber_first = 0;
2434 581 tempheader.compilerversionnumber_second = 0;
2435 581 tempheader.compilerversionnumber_third = 0;
2436 581 tempheader.compilerversionnumber_fourth = 0;
2437 581 tempheader.developerid = 0;
2438
2439 581 memset(tempheader.made_in_module_name, 0, 1024);
2440 581 memset(tempheader.build_datestamp, 0, 256);
2441 581 memset(tempheader.build_timestamp, 0, 256);
2442 }
2443
2444
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 581 times.
763 if ( version >= 5 )
2445 {
2446
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(tempheader.build_timezone,6,f))
2447 {
2448 return qe_invalid;
2449 }
2450 182 }
2451 else // < 5
2452 {
2453 581 memset(tempheader.build_timezone, 0, 6);
2454 }
2455
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 581 times.
763 if ( version >= 6 )
2456 {
2457 byte b;
2458
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&b,f))
2459 {
2460 return qe_invalid;
2461 }
2462 182 tempheader.external_zinfo = b?true:false;
2463 182 read_zinfo = true;
2464 182 }
2465
2466
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 581 times.
763 if(version >= 7)
2467 {
2468
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2469 {
2470 return qe_invalid;
2471 }
2472 182 }
2473 else
2474 {
2475 581 tempheader.new_version_is_nightly = false;
2476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 581 times.
581 if(tempheader.zelda_version < 0x255)
2477 {
2478
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
581 switch(tempheader.zelda_version)
2479 {
2480 case 0x254:
2481 tempheader.version_major = 2;
2482 tempheader.version_minor = 54;
2483 break;
2484 case 0x250:
2485
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 399 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 28 times.
✓ Branch 15 taken 16 times.
522 switch(tempheader.build)
2486 {
2487 case 19:
2488 tempheader.version_major = 2;
2489 tempheader.version_minor = 50;
2490 tempheader.new_version_id_gamma = 1;
2491 break;
2492 case 20:
2493 tempheader.version_major = 2;
2494 tempheader.version_minor = 50;
2495 tempheader.new_version_id_gamma = 2;
2496 break;
2497 case 21:
2498 tempheader.version_major = 2;
2499 tempheader.version_minor = 50;
2500 tempheader.new_version_id_gamma = 3;
2501 break;
2502 case 22:
2503 tempheader.version_major = 2;
2504 tempheader.version_minor = 50;
2505 tempheader.new_version_id_gamma = 4;
2506 break;
2507 case 23:
2508 tempheader.version_major = 2;
2509 tempheader.version_minor = 50;
2510 tempheader.new_version_id_gamma = 5;
2511 break;
2512 case 24:
2513 33 tempheader.version_major = 2;
2514 33 tempheader.version_minor = 50;
2515 33 tempheader.new_version_id_release = -1;
2516 33 break;
2517 case 25:
2518 tempheader.version_major = 2;
2519 tempheader.version_minor = 50;
2520 tempheader.version_patch = 1;
2521 tempheader.new_version_id_gamma = 1;
2522 break;
2523 case 26:
2524 24 tempheader.version_major = 2;
2525 24 tempheader.version_minor = 50;
2526 24 tempheader.version_patch = 1;
2527 24 tempheader.new_version_id_gamma = 2;
2528 24 break;
2529 case 27:
2530 tempheader.version_major = 2;
2531 tempheader.version_minor = 50;
2532 tempheader.version_patch = 1;
2533 tempheader.new_version_id_gamma = 3;
2534 break;
2535 case 28:
2536 6 tempheader.version_major = 2;
2537 6 tempheader.version_minor = 50;
2538 6 tempheader.version_patch = 1;
2539 6 tempheader.new_version_id_release = -1;
2540 6 break;
2541 case 29:
2542 399 tempheader.version_major = 2;
2543 399 tempheader.version_minor = 50;
2544 399 tempheader.version_patch = 2;
2545 399 tempheader.new_version_id_release = -1;
2546 399 break;
2547 case 30:
2548 tempheader.version_major = 2;
2549 tempheader.version_minor = 50;
2550 tempheader.version_patch = 3;
2551 tempheader.new_version_id_gamma = 1;
2552 break;
2553 case 31:
2554 16 tempheader.version_major = 2;
2555 16 tempheader.version_minor = 53;
2556 16 tempheader.new_version_id_gamma = -1;
2557 16 break;
2558 case 32:
2559 28 tempheader.version_major = 2;
2560 28 tempheader.version_minor = 53;
2561 28 tempheader.new_version_id_release = -1;
2562 28 break;
2563 case 33:
2564 16 tempheader.version_major = 2;
2565 16 tempheader.version_minor = 53;
2566 16 tempheader.version_patch = 1;
2567 16 break;
2568 }
2569 522 break;
2570
2571 case 0x211:
2572 tempheader.version_major = 2;
2573 tempheader.version_minor = 11;
2574 tempheader.new_version_id_beta = tempheader.build;
2575 break;
2576 case 0x210:
2577 59 tempheader.version_major = 2;
2578 59 tempheader.version_minor = 10;
2579 59 tempheader.new_version_id_beta = tempheader.build;
2580 59 break;
2581 }
2582 581 }
2583 }
2584
2585
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 625 times.
763 if (version>=9)
2586 {
2587 138 std::string version_string;
2588
2/4
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
✗ Branch 3 not taken.
138 if(!p_getcstr(&version_string, f))
2589 {
2590 return qe_invalid;
2591 }
2592
2593 138 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2594 138 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 }
2596 else
2597 {
2598 625 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2599 }
2600 }
2601
2602
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 775 times.
787 if(printmetadata)
2603 {
2604
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2605 12 }
2606
2607 //{ Version Warning
2608
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 int32_t vercmp = tempheader.compareVer();
2609
3/6
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 787 times.
✗ Branch 5 not taken.
787 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2610
2/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 787 times.
✗ Branch 3 not taken.
787 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2611
4/6
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
✓ Branch 3 taken 649 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 138 times.
925 if(vercmp > 0 || (!vercmp &&
2612
2/4
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
✗ Branch 3 not taken.
138 (astatecmp > 0 || (!astatecmp &&
2613 138 avercmp > 0))))
2614 {
2615 bool r = true;
2616 if(loadquest_report)
2617 {
2618 enter_sys_pal();
2619 AlertDialog("Quest saved in newer version",
2620 "This quest was last saved in a newer version of ZQuest."
2621 " Attempting to load this quest may not work correctly; to"
2622 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2623 "\n\nWould you like to continue loading anyway? (Not recommended)",
2624 [&](bool ret,bool)
2625 {
2626 r = ret;
2627 }).show();
2628 exit_sys_pal();
2629 }
2630 if(!r)
2631 return qe_silenterr;
2632 }
2633
2/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 787 times.
✗ Branch 3 not taken.
787 else if(tempheader.compareDate() > 0)
2634 {
2635 bool r = true;
2636 if(loadquest_report)
2637 {
2638 enter_sys_pal();
2639 AlertDialog("Quest saved in newer build",
2640 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2641 " issues loading in this build."
2642 "\n{}"
2643 "\n\nWould you like to continue loading anyway?",
2644 tempheader.getVerCmpStr()),
2645 [&](bool ret,bool)
2646 {
2647 r = ret;
2648 }).show();
2649 exit_sys_pal();
2650 }
2651 if(!r)
2652 return qe_silenterr;
2653 }
2654 //}
2655
2656 787 read_ext_zinfo = tempheader.external_zinfo;
2657
2658
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 *Header = tempheader;
2659 787 map_count=temp_map_count;
2660 787 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2661
2662
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 unpack_qrs();
2663
2664 787 return 0;
2665 811 }
2666
2667 6587 int32_t readrules(PACKFILE *f, zquestheader *Header)
2668 {
2669
2/2
✓ Branch 0 taken 6564 times.
✓ Branch 1 taken 23 times.
6587 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6587 times.
6587 if (should_skip)
2671 return 0;
2672
2673 int32_t dummy;
2674 6587 zquestheader tempheader = *Header;
2675 6587 word s_version=0;
2676 6587 dword compatrule_version=0;
2677
2678
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 6141 times.
6587 if(tempheader.zelda_version >= 0x193)
2679 {
2680 //section version info
2681
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&s_version,f))
2682 {
2683 return qe_invalid;
2684 }
2685
2686 446 FFCore.quest_format[vRules] = s_version;
2687
2688
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&dummy,f))
2689 {
2690 return qe_invalid;
2691 }
2692
2693
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 264 times.
446 if(s_version > 16)
2694 {
2695
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&compatrule_version,f))
2696 {
2697 return qe_invalid;
2698 }
2699 182 }
2700 446 FFCore.quest_format[vCompatRule] = compatrule_version;
2701
2702 //section size
2703
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&dummy,f))
2704 {
2705 return qe_invalid;
2706 }
2707
2708
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 182 times.
446 if ( s_version < 15 )
2709 {
2710 //finally... section data
2711
2/4
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
✗ Branch 3 not taken.
264 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2712 {
2713 return qe_invalid;
2714 }
2715 264 }
2716 else
2717 {
2718
2719
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2720 {
2721 return qe_invalid;
2722 }
2723
2724 }
2725 446 }
2726
2727 //{ bunch of compat stuff
2728 6587 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2729
2730
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 6118 times.
6587 unpack_qrs();
2731
2732
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<2)
2733 {
2734
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2735
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2736
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2737
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2738
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2739
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2740
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2741
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2742
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2743
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2744
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2745
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2746
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2747
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2748
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2749
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2750
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2751
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2752
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2753 82 }
2754
2755 //Now, do any updates...
2756
3/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
469 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2757 {
2758
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2759
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2760
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2761
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2762
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2763 82 }
2764
2765
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
469 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2766 {
2767
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2768 23 }
2769
2770
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
469 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2771 {
2772
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2773 23 }
2774
2775
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
469 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2776 {
2777
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2778 23 }
2779
2780
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(tempheader.zelda_version <= 0x210)
2781 {
2782
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2783 82 }
2784
2785
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 410 times.
469 if(tempheader.zelda_version == 0x210)
2786 {
2787
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2788
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2789
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2790 59 }
2791
2792
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(tempheader.zelda_version <= 0x210)
2793 {
2794
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2795
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2796 82 }
2797
2798 //might not be correct
2799
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 446 times.
469 if(tempheader.zelda_version < 0x210)
2800 {
2801
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2802
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2803
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2804 23 }
2805
2806
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(tempheader.zelda_version < 0x211)
2807 {
2808
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2809 82 }
2810
2811
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 464 times.
469 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2812 {
2813
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 447 times.
469 set_qr(qr_192b163_WARP,1);
2814 22 }
2815
2816
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 47 times.
22 if(tempheader.zelda_version == 0x210)
2817 {
2818
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2819
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2820
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2821 59 }
2822
2823
3/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 281 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
106 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2824 {
2825
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 199 times.
281 set_qr(qr_OLDPICKUP,1);
2826 82 }
2827
2828
3/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
469 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2829 {
2830
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2831
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2832 82 }
2833
2834
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2835 {
2836
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2837 82 }
2838
2839
4/4
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 264 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 172 times.
469 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2840 {
2841
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_PEAHATCLOCKVULN, 1);
2842 33 }
2843
2844
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
469 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2845 {
2846
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 205 times.
287 set_qr(qr_OLD_DOORREPAIR, 1);
2847 82 }
2848
2849
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
264 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2850 {
2851
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
328 set_qr(qr_OLD_SECRETMONEY, 1);
2852 82 }
2853
2854
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
264 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2855 {
2856
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 189 times.
328 set_qr(qr_OLD_POTION_OR_HC, 1);
2857 139 }
2858
2859
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
321 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2860 {
2861
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 132 times.
271 set_qr(qr_OFFSCREENWEAPONS, 1);
2862 139 }
2863
2864 //Bombchu fix.
2865
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 205 times.
321 if(tempheader.zelda_version == 0x250)
2866 {
2867
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 172 times.
205 if ( tempheader.build == 24 ) //2.50.0
2868 {
2869
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2870 33 }
2871
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 199 times.
205 if ( tempheader.build == 28 ) //2.50.1
2872 {
2873
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2874 6 }
2875
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 123 times.
205 if ( tempheader.build == 29 ) //2.50.2
2876 {
2877
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2878 82 }
2879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if ( tempheader.build == 30 ) //2.50.3RC1
2880 {
2881 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2882 }
2883 205 }
2884
2885
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
321 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2886 {
2887 // qr_OFFSETEWPNCOLLISIONFIX
2888 // All 'official' quests need this disabled.
2889 // All 2.10 and lower quests need this enabled to preseve compatability.
2890 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2891
2892 //~Gleeok
2893
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 126 times.
271 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2894
2895 // Broke in build 695
2896
3/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
145 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2897
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_BROKENSTATUES, 1);
2898 145 }
2899
11/14
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 451 times.
✓ Branch 2 taken 446 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 570 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 570 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 553 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
327 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2900 {
2901
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2902 22 }
2903
8/8
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 370 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 198 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 182 times.
✓ Branch 7 taken 16 times.
575 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2904 {
2905
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 288 times.
559 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2906 271 }
2907
2908
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 205 times.
287 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2909 {
2910
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2911 82 }
2912
2913
4/6
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 182 times.
287 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2914 {
2915
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 136 times.
151 set_qr(qr_STEP_IS_FLOAT,0);
2916 287 }
2917
2918
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if ( tempheader.zelda_version < 0x250 )
2919 {
2920
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
2921 82 }
2922
2923
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version < 3)
2924 {
2925
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
2926
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
2927 82 }
2928
2929
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<4)
2930 {
2931
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
2932 82 }
2933
2934
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<5)
2935 {
2936
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2937 82 }
2938
2939
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<6)
2940 {
2941
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
2942 82 }
2943
2944
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<7) // January 2008
2945 {
2946
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
2947
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
2948 82 }
2949
2950
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<8)
2951 {
2952
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
2953 82 }
2954 else
2955 {
2956
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 set_bit(deprecated_rules, 12, 0);
2957 }
2958
2959
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<9) // October 2008
2960 {
2961
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
2962
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
2963
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
2964
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
2965 82 }
2966
2967
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<10) // December 2008
2968 {
2969
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
2970
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
2971 82 }
2972
2973
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<11) // April 2009
2974 {
2975
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
2976 82 }
2977
2978 // This served no purpose.
2979 // if(s_version<12) // December 2009
2980 // {
2981 // set_qr(qr_BRKBLSHLDS_DEP,0);
2982 // set_qr(qr_OLDTRIBBLES_DEP,0);
2983 // }
2984
2985 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
2986
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version < 13)
2987 {
2988
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
2989 82 }
2990
2991 // Not entirely sure this is the best place for this...
2992 //2.50.2 bitmap offset fix
2993 469 memset(extra_rules, 0, EXTRARULES_SIZE);
2994
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
469 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2995 {
2996
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 142 times.
287 set_er(er_BITMAPOFFSET, 1);
2997
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 set_qr(qr_BITMAPOFFSETFIX, 1);
2998 145 }
2999 //required because quest templates also used this bit, although
3000 //it never did anything, before. -Z
3001
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 122 times.
327 if ( tempheader.zelda_version == 0x250 )
3002 {
3003
5/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 107 times.
205 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3004 {
3005
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_er(er_BITMAPOFFSET, 0);
3006
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_qr(qr_BITMAPOFFSETFIX, 0);
3007 98 }
3008 205 }
3009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
327 if ( tempheader.zelda_version == 0x254 )
3010 {
3011 set_er(er_BITMAPOFFSET, 0);
3012 set_qr(qr_BITMAPOFFSETFIX, 0);
3013 }
3014
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
327 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3015 {
3016 set_er(er_BITMAPOFFSET, 0);
3017 set_qr(qr_BITMAPOFFSETFIX, 0);
3018 }
3019 //optimise fast drawing for older versions.
3020
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
327 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3021 {
3022
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 96 times.
327 set_qr(qr_OLDSPRITEDRAWS, 1);
3023 287 }
3024 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3025 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3026 //older quests can set the rule by hand. We need a new qst.dat again.
3027
4/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 182 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3028 {
3029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 364 times.
364 set_qr(qr_OLDEWPNPARENT, 1);
3030 }
3031
4/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 182 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3032 {
3033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 364 times.
364 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3034 }
3035
4/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 182 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3036 {
3037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 364 times.
364 set_qr(qr_OLDQUESTMISC, 1);
3038 }
3039
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x254 )
3040 {
3041
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3042
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDEWPNPARENT, 0);
3043
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDQUESTMISC, 0);
3044 287 }
3045
3046 //item scripts continue to run
3047
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3048 {
3049
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3050
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3051
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3052
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3053
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3054
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3055
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3056 287 }
3057
3058
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3059 {
3060
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3061 287 }
3062
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3063 {
3064
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_TRACESCRIPTIDS, 0);
3065
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3066
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3067
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_250DIVISION,1);
3068
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3069
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3070
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_FORCE_INLINE,0);
3071
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BINARY_32BIT,0);
3072
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 278 times.
287 if ( get_qr(qr_SELECTAWPN) )
3073 {
3074
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3075 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3076 //Now they **do**, unless you disable that behaviour.
3077 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3078 //now enable the disable L/R item swap on load.
3079 9 }
3080
3081 287 }
3082
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3083 {
3084 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3085
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3086 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3087 //animations ending earlier than they should.
3088
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3089 //Enemies would ignore solidity on the top half of combos
3090
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3091 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3092
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3093 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3094
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3095 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3096
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3097 287 }
3098
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x255 )
3099 {
3100
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NOFFCWAITDRAW, 1);
3101
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NOITEMWAITDRAW, 1);
3102
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3103
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3104 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3105 287 }
3106
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3107 {
3108
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3109 287 }
3110
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3111 {
3112
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_OLD_PRINTF_ARGS, 1);
3113 287 }
3114
3115
3116
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3117 {
3118
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_BROKEN_RING_POWER, 1);
3119 287 }
3120
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3121 {
3122
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3123 287 }
3124
5/6
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 136 times.
✓ Branch 5 taken 46 times.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3125 {
3126
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3127 287 }
3128
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
333 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3129 {
3130 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
333 if(get_qr(qr_SET_XBUTTON_ITEMS))
3132 set_qr(qr_SET_YBUTTON_ITEMS,1);
3133 287 }
3134
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3135 {
3136
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3137 287 }
3138
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3139 {
3140
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_OLD_CHEST_COLLISION,1);
3141 287 }
3142
3143
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x254 )
3144 {
3145
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3146 287 }
3147 //Sideview spikes in 2.50.0
3148
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
287 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3149 {
3150
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 178 times.
317 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3151 139 }
3152 //more 2.50 fixes -Z
3153
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
321 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3154 {
3155
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 52 times.
271 set_qr(qr_MELEEMAGICCOST, 0);
3156
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3157
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_OLDMIRRORCOMBOS, 1);
3158
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENBOOKCOST, 1);
3159
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENCHARINTDRAWING, 1);
3160
3161 227 }
3162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 409 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
409 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3163 {
3164 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3165 set_qr(qr_MELEEMAGICCOST, 1);
3166 }
3167
3168
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 386 times.
409 if(tempheader.zelda_version < 0x193)
3169 {
3170
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3171 23 }
3172
3173
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 122 times.
409 if(tempheader.zelda_version < 0x255)
3174 {
3175
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDINFMAGIC, 1);
3176 287 }
3177
3178
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 327 times.
409 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3179 {
3180
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3181 82 }
3182
3183
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
409 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3184 {
3185
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 122 times.
409 set_qr(qr_OLD_F6,1);
3186 287 }
3187
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3188 {
3189
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3190 287 }
3191
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3192 {
3193
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3194 287 }
3195
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3196 {
3197
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3198 287 }
3199 //}
3200
3201
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3202
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3203
3204
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 2) //Old CSet2 Handling
3205
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDCS2,1);
3206
3207
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3208
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3209
3210
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3211
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3212
3213
3/4
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 82 times.
287 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3214
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3215
3216
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3217
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3218
3219
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3220
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3221
3222
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3223
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3224
3225
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 9)
3226 {
3227 //Hardcoded BS Patras
3228
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_BS_PATRA,1);
3229 //Hardcoded Patra Inner Eye offsets
3230
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3231 //Broken 'Big enemy' animation style
3232
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3233 //Broken Attribute 31/32
3234
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3235 287 }
3236
3237
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 10) //Shared candle use limits
3238
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3239
3240
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 11) //No cross-screen return points
3241
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_RESPAWN_POINTS,1);
3242
3243
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 12)
3244 {
3245 //Old fire trail duration
3246
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3247 //Old Intro String in Ganon Room Behavior
3248
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
287 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3249
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 else set_qr(qr_GANONINTRO,1);
3250 287 }
3251
3252
2/4
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 287 times.
287 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3253 set_qr(qr_ANONE_NOANIM,1);
3254
3255
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 14) //Old Bridge Combo Behavior
3256
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3257
3258
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 15) //Broken Z3 Animation
3259
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3260
3261
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3262
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3263
3264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 17)
3265 {
3266 //Old Quake/DrawYOffset behavior
3267 //set_qr(qr_OLD_DRAWOFFSET,1);
3268 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3269 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3270 287 }
3271
3272
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 18)
3273 {
3274 //Broken DrawScreen Derivative Functions
3275
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3276 //Scrolling Cancels Charge
3277
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3278 287 }
3279
3280
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3281
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3282
3283
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 20)
3284
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3285
3286
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 21)
3287 {
3288
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3289
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3290
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3291
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_BUG_NET,1);
3292
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3293 287 }
3294
3295
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 22)
3296
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3297
3298
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 23)
3299
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_HALF_MAGIC,1);
3300
3301
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 24)
3302 {
3303
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3304
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3305 287 }
3306
3307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 25)
3308 {
3309
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
287 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3310
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3311
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3312 287 }
3313
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 26)
3314 {
3315
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3316
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_POLVIRE_NO_SHADOW,1);
3317
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3318 287 }
3319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3320 {
3321
2/2
✓ Branch 0 taken 86387 times.
✓ Branch 1 taken 287 times.
86674 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3322
1/2
✓ Branch 0 taken 86387 times.
✗ Branch 1 not taken.
86387 set_qr(q,0);
3323
2/2
✓ Branch 0 taken 1722 times.
✓ Branch 1 taken 287 times.
2009 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3324
1/2
✓ Branch 0 taken 1722 times.
✗ Branch 1 not taken.
1722 set_qr(q,0);
3325 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3326 287 }
3327
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
287 if(compatrule_version < 28)
3328
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3329
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 29)
3330
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3331
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 30)
3332 {
3333
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_DECO_2_YOFFSET,1);
3334
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_SCREENSTATE_80s_BUG,1);
3335 292 }
3336
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 31)
3337 {
3338
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3339
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3340 292 }
3341
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 32)
3342
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3343
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 33)
3344
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_NO_LIFT_SPRITE,1);
3345
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 34)
3346 {
3347
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3348
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3349
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3350
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3351 292 }
3352
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 3 times.
297 if(compatrule_version < 35)
3353 {
3354
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3355
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3356 294 }
3357
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 3 times.
297 if(compatrule_version < 36)
3358
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_OLD_SHALLOW_SFX,1);
3359
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 1 times.
297 if(compatrule_version < 37)
3360
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3361
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 1 times.
299 if(compatrule_version < 38)
3362
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3363
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 1 times.
299 if(compatrule_version < 39)
3364
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3365
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 1 times.
299 if(compatrule_version < 40)
3366
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3367
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
299 if(compatrule_version < 41)
3368
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKENHITBY,1);
3369
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
303 if(compatrule_version < 42)
3370
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3371
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
303 if(compatrule_version < 43)
3372
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_OLD_BOMB_HITBOXES,1);
3373
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
303 if(compatrule_version < 44)
3374
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3375
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
303 if(compatrule_version < 45)
3376
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3377
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
303 if(compatrule_version < 46)
3378
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3379
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
303 if(compatrule_version < 47)
3380 {
3381
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3382
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3383 304 }
3384
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 48)
3385
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_GUY_HANDLING,1);
3386
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 49)
3387
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3388
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 50)
3389
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3390
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 51)
3391
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3392
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if (compatrule_version < 52)
3393
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3394
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 53)
3395 {
3396
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_SUBSCR,1);
3397
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3398
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3399 304 }
3400
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 54)
3401
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3402
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 55)
3403
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3404
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 56)
3405
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3406
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 57)
3407
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3408
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 58)
3409
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3410
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 59)
3411
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3412
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 60)
3413
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3414
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 61)
3415
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3416
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 62)
3417
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3418
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 4 times.
309 if(compatrule_version < 63)
3419 {
3420
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_LIFTSWIM,1);
3421
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3422 305 }
3423
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 4 times.
309 if(compatrule_version < 64)
3424
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3425
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 21 times.
309 if(compatrule_version < 65)
3426
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3427
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
351 if(compatrule_version < 66)
3428
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3429
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if(compatrule_version < 67)
3430
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3431
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if(compatrule_version < 68)
3432
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3433
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if(compatrule_version < 69)
3434
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3435
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if (compatrule_version < 70)
3436
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_CONVEYORS, 1);
3437
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if (compatrule_version < 71)
3438
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3439
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if (compatrule_version < 72)
3440
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3441
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if (compatrule_version < 73)
3442 {
3443
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_OLD_LANDING_SFX, 1);
3444
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3445 332 }
3446
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
353 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3447
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3448
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 352 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
684 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3449
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3450
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 683 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
1015 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3451
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3452
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 996 times.
1346 if (compatrule_version < 77)
3453
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3454
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 996 times.
1346 if (compatrule_version < 78)
3455
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3456
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 996 times.
1346 if (compatrule_version < 79)
3457
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 set_qr(qr_BROKEN_SYSTEM_COLORS, 1);
3458
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 996 times.
1346 if (compatrule_version < 80)
3459
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 set_qr(qr_ZS_OLD_SUSPEND_FFC, 1);
3460
3461
3/4
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 1015 times.
✓ Branch 2 taken 331 times.
✗ Branch 3 not taken.
1346 if (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 6) < 0)
3462
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 546 times.
1015 set_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE, 1);
3463
3464
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 331 times.
800 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3465
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 182 times.
469 if (s_version < 16)
3466
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3467
3468
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 *Header = tempheader;
3469
3470 469 return 0;
3471 12705 }
3472
3473 3983401 void init_msgstr(MsgStr *str)
3474 {
3475
2/4
✓ Branch 0 taken 3983401 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3983401 times.
3983401 str->setFromLegacyEncoding("");
3476 3983401 str->nextstring=0;
3477 3983401 str->tile=0;
3478 3983401 str->cset=0;
3479 3983401 str->trans=false;
3480 3983401 str->font=font_zfont;
3481 3983401 str->y=32;
3482 3983401 str->sfx=18;
3483 3983401 str->listpos=0;
3484 3983401 str->x=24;
3485 3983401 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3486 3983401 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3487 3983401 str->hspace=0;
3488 3983401 str->vspace=0;
3489 3983401 str->stringflags=0;
3490 3983401 str->margins[up] = 8;
3491 3983401 str->margins[down] = 0;
3492 3983401 str->margins[left] = 8;
3493 3983401 str->margins[right] = 8;
3494 3983401 str->portrait_tile = 0;
3495 3983401 str->portrait_cset = 0;
3496 3983401 str->portrait_x = 0;
3497 3983401 str->portrait_y = 0;
3498 3983401 str->portrait_tw = 1;
3499 3983401 str->portrait_th = 1;
3500 3983401 str->shadow_type = 0;
3501 3983401 str->shadow_color = 0;
3502 3983401 str->drawlayer = 6;
3503 3983401 }
3504
3505 469 void init_msgstrings(int32_t start, int32_t end)
3506 {
3507
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 469 times.
469 if(end <= start || end-start > msg_strings_size)
3508 return;
3509
3510
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 3842048 times.
3842517 for(int32_t i=start; i<end; i++)
3511 {
3512 3842048 init_msgstr(&MsgStrings[i]);
3513 3842048 MsgStrings[i].listpos=i;
3514 3842048 }
3515
3516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(start==0)
3517 {
3518
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 469 times.
469 MsgStrings[0].setFromLegacyEncoding("(None)");
3519 469 MsgStrings[0].listpos = 0;
3520 469 }
3521 469 }
3522
3523 470 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3524 {
3525
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 446 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3526
3527 470 MsgStr tempMsgString;
3528
1/2
✓ Branch 0 taken 470 times.
✗ Branch 1 not taken.
470 init_msgstr(&tempMsgString);
3529
3530 470 word temp_msg_count=0;
3531 word temp_expansion[16];
3532 470 memset(temp_expansion, 0, 16*sizeof(word));
3533 470 char buf[8193] = {0};
3534
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 446 times.
470 if(Header->zelda_version < 0x193)
3535 {
3536 byte tempbyte;
3537 24 int32_t strings_to_read=0;
3538
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3539
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3540
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3541
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3542 {
3543 18 strings_to_read=128;
3544 18 temp_msg_count=Header->old_str_count;
3545
3546 // Some sort of string count corruption seems to be common in old quests
3547
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3548 {
3549 temp_msg_count=128;
3550 }
3551 18 }
3552
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3553 {
3554 strings_to_read=255;
3555 temp_msg_count=Header->old_str_count;
3556 }
3557 else
3558 {
3559
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3560 {
3561 return qe_invalid;
3562 }
3563
3564 6 strings_to_read=temp_msg_count;
3565
3566
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3567 {
3568 Z_message("Reallocating string buffer...\n");
3569
3570 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3571 // return qe_nomem;
3572
3573 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3574 delete[] MsgStrings;
3575 MsgStrings = new MsgStr[MAXMSGS];
3576 msg_strings_size = MAXMSGS;
3577 for(auto q = 0; q < msg_strings_size; ++q)
3578 {
3579 MsgStrings[q].clear();
3580 }
3581 }
3582 }
3583
3584 //reset the message strings
3585
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3586
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3587
3588
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3589 {
3590
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3591 2550 tempMsgString.listpos = x;
3592
3593
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3594 {
3595 return qe_invalid;
3596 }
3597
3598 2550 buf[74] = '\0';
3599
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3600
3601
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3602 {
3603 return qe_invalid;
3604 }
3605
3606
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3607
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3608 {
3609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3610
3611
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3612 {
3613 return qe_invalid;
3614 }
3615
3616
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3617 {
3618 return qe_invalid;
3619 }
3620 2304 }
3621 else
3622 {
3623
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3624 {
3625 return qe_invalid;
3626 }
3627
3628
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3629 {
3630 return qe_invalid;
3631 }
3632 }
3633
3634
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3635 {
3636
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3637 2549 }
3638 2550 }
3639 24 }
3640 else
3641 {
3642 int32_t dummy_int;
3643 word s_version;
3644
3645 //section version info
3646
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&s_version,f))
3647 {
3648 return qe_invalid;
3649 }
3650
3651 446 FFCore.quest_format[vStrings] = s_version;
3652
3653
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!read_deprecated_section_cversion(f))
3654 {
3655 return qe_invalid;
3656 }
3657
3658 //section size
3659
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&dummy_int,f))
3660 {
3661 return qe_invalid;
3662 }
3663
3664 //finally... section data
3665
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&temp_msg_count,f))
3666 {
3667 return qe_invalid;
3668 }
3669
3670
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
446 if(temp_msg_count >= msg_strings_size && !should_skip)
3671 {
3672 Z_message("Reallocating string buffer...\n");
3673
3674 delete[] MsgStrings;
3675 MsgStrings = new MsgStr[MAXMSGS];
3676 msg_strings_size = MAXMSGS;
3677 for(auto q = 0; q < msg_strings_size; ++q)
3678 {
3679 MsgStrings[q].clear();
3680 }
3681 }
3682
3683 //reset the message strings
3684
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 182 times.
446 if(s_version < 7)
3685
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3686
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if (!should_skip)
3687
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 init_msgstrings(0,msg_strings_size);
3688
3689 446 int32_t string_length=(s_version<2)?73:145;
3690
3691
2/2
✓ Branch 0 taken 138333 times.
✓ Branch 1 taken 446 times.
138779 for(int32_t i=0; i<temp_msg_count; i++)
3692 {
3693
1/2
✓ Branch 0 taken 138333 times.
✗ Branch 1 not taken.
138333 init_msgstr(&tempMsgString);
3694 138333 tempMsgString.listpos = i;
3695
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 132539 times.
138333 if(s_version > 8)
3696 {
3697
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_igetl(&string_length,f))
3698 {
3699 return qe_invalid;
3700 }
3701 5794 }
3702
3703
2/4
✓ Branch 0 taken 138333 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 138333 times.
138333 if (string_length < 0 || string_length > 8193)
3704 {
3705 return qe_invalid;
3706 }
3707
3708
2/2
✓ Branch 0 taken 137781 times.
✓ Branch 1 taken 552 times.
138333 if (string_length > 0)
3709 {
3710
2/4
✓ Branch 0 taken 137781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137781 times.
✗ Branch 3 not taken.
137781 if (!pfread(buf, string_length, f))
3711 {
3712 return qe_invalid;
3713 }
3714 137781 }
3715 else
3716 {
3717 552 buf[0] = 0;
3718 }
3719
3720
2/4
✓ Branch 0 taken 138333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138333 times.
✗ Branch 3 not taken.
138333 if(!p_igetw(&tempMsgString.nextstring,f))
3721 {
3722 return qe_invalid;
3723 }
3724
3725
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 104720 times.
138333 if(s_version<2)
3726 {
3727 33613 buf[72] = '\0';
3728
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33613 times.
33613 tempMsgString.setFromLegacyEncoding(buf);
3729 33613 }
3730 else
3731 {
3732 // June 2008: A bug corrupted the last 4 chars of a string.
3733 // Discard these.
3734
1/2
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
104720 if(s_version<3)
3735 {
3736 for(int32_t j=140; j<144; j++)
3737 {
3738 buf[j] = '\0';
3739 }
3740 }
3741
1/2
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
104720 if(string_length > 8192) string_length = 8192;
3742 104720 buf[string_length]='\0'; //Force-terminate
3743
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104720 times.
104720 tempMsgString.setFromLegacyEncoding(buf);
3744
3745
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 98926 times.
104720 if ( s_version >= 6 )
3746 {
3747
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_igetl(&tempMsgString.tile,f))
3748 {
3749 return qe_invalid;
3750 }
3751 5794 }
3752 else
3753 {
3754
2/4
✓ Branch 0 taken 98926 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98926 times.
✗ Branch 3 not taken.
98926 if(!p_igetw(&tempMsgString.tile,f))
3755 {
3756 return qe_invalid;
3757 }
3758 }
3759
3760
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.cset,f))
3761 {
3762 return qe_invalid;
3763 }
3764
3765 byte dummy_char;
3766
3767
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3768 {
3769 return qe_invalid;
3770 }
3771
3772 104720 tempMsgString.trans=dummy_char!=0;
3773
3774
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.font,f))
3775 {
3776 return qe_invalid;
3777 }
3778
3779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104720 times.
104720 if(s_version < 5)
3780 {
3781 if(!p_getc(&tempMsgString.y,f))
3782 {
3783 return qe_invalid;
3784 }
3785 }
3786 else
3787 {
3788
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_igetw(&tempMsgString.x,f))
3789 {
3790 return qe_invalid;
3791 }
3792
3793
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_igetw(&tempMsgString.y,f))
3794 {
3795 return qe_invalid;
3796 }
3797
3798
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_igetw(&tempMsgString.w,f))
3799 {
3800 return qe_invalid;
3801 }
3802
3803
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_igetw(&tempMsgString.h,f))
3804 {
3805 return qe_invalid;
3806 }
3807
3808
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.hspace,f))
3809 {
3810 return qe_invalid;
3811 }
3812
3813
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.vspace,f))
3814 {
3815 return qe_invalid;
3816 }
3817
3818
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.stringflags,f))
3819 {
3820 return qe_invalid;
3821 }
3822 }
3823
3824
2/2
✓ Branch 0 taken 98926 times.
✓ Branch 1 taken 5794 times.
104720 if(s_version >= 7)
3825 {
3826
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 23176 times.
28970 for(int32_t q = 0; q < 4; ++q)
3827 {
3828
2/4
✓ Branch 0 taken 23176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23176 times.
✗ Branch 3 not taken.
23176 if(!p_getc(&tempMsgString.margins[q],f))
3829 {
3830 return qe_invalid;
3831 }
3832 23176 }
3833
3834
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_igetl(&tempMsgString.portrait_tile,f))
3835 {
3836 return qe_invalid;
3837 }
3838
3839
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.portrait_cset,f))
3840 {
3841 return qe_invalid;
3842 }
3843
3844
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.portrait_x,f))
3845 {
3846 return qe_invalid;
3847 }
3848
3849
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.portrait_y,f))
3850 {
3851 return qe_invalid;
3852 }
3853
3854
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.portrait_tw,f))
3855 {
3856 return qe_invalid;
3857 }
3858
3859
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.portrait_th,f))
3860 {
3861 return qe_invalid;
3862 }
3863 5794 }
3864
3865
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 98926 times.
104720 if(s_version >= 8)
3866 {
3867
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.shadow_type,f))
3868 {
3869 return qe_invalid;
3870 }
3871
3872
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.shadow_color,f))
3873 {
3874 return qe_invalid;
3875 }
3876 5794 }
3877
3878
2/2
✓ Branch 0 taken 5485 times.
✓ Branch 1 taken 99235 times.
104720 if(s_version >= 10)
3879 {
3880
2/4
✓ Branch 0 taken 5485 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5485 times.
✗ Branch 3 not taken.
5485 if(!p_getc(&tempMsgString.drawlayer,f))
3881 {
3882 return qe_invalid;
3883 }
3884 5485 }
3885
3886
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.sfx,f))
3887 {
3888 return qe_invalid;
3889 }
3890
3891
1/2
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
104720 if(s_version>3)
3892 {
3893
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_igetw(&tempMsgString.listpos,f))
3894 {
3895 return qe_invalid;
3896 }
3897 104720 }
3898 }
3899
3900
1/2
✓ Branch 0 taken 138333 times.
✗ Branch 1 not taken.
138333 if (!should_skip)
3901 {
3902
1/2
✓ Branch 0 taken 138333 times.
✗ Branch 1 not taken.
138333 MsgStrings[i].copyAll(tempMsgString);
3903 138333 }
3904 138333 }
3905 }
3906
3907
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 469 times.
470 if (!should_skip)
3908 469 msg_count=temp_msg_count;
3909
3910 470 return 0;
3911 470 }
3912
3913 470 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
3914 {
3915
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 446 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
3916
3917
3/4
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
476 if((Header->zelda_version < 0x192)||
3918
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 446 times.
452 ((Header->zelda_version == 0x192)&&(Header->build<158)))
3919 {
3920 18 return 0;
3921 }
3922
3923 452 word temp_door_combo_set_count=0;
3924 DoorComboSet tempDoorComboSet;
3925 word dummy_word;
3926 int32_t dummy_long;
3927 byte padding;
3928 452 int32_t s_version = 0;
3929
3930
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 451 times.
452 if (!should_skip)
3931 {
3932 451 DoorComboSets = {};
3933 451 DoorComboSetNames = {};
3934 451 }
3935
3936
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 446 times.
452 if(Header->zelda_version > 0x192)
3937 {
3938 //section version info
3939
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&s_version,f))
3940 {
3941 return qe_invalid;
3942 }
3943
3944 446 FFCore.quest_format[vDoors] = s_version;
3945
3946
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&dummy_word,f))
3947 {
3948 return qe_invalid;
3949 }
3950
3951 //section size
3952
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy_long,f))
3953 {
3954 return qe_invalid;
3955 }
3956 446 }
3957
3958 //finally... section data
3959
1/2
✓ Branch 0 taken 452 times.
✗ Branch 1 not taken.
452 if(!p_igetw(&temp_door_combo_set_count,f))
3960 {
3961 return qe_invalid;
3962 }
3963
3964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452 times.
452 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
3965 {
3966 return qe_invalid;
3967 }
3968
3969
2/2
✓ Branch 0 taken 5334 times.
✓ Branch 1 taken 452 times.
5786 for(int32_t i=0; i<temp_door_combo_set_count; i++)
3970 {
3971 5334 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
3972
3973 //name
3974 char name[21];
3975
1/2
✓ Branch 0 taken 5334 times.
✗ Branch 1 not taken.
5334 if(!pfread(&name,sizeof(name),f))
3976 {
3977 return qe_invalid;
3978 }
3979
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5320 times.
5334 if (!should_skip)
3980 5320 DoorComboSetNames[i] = name;
3981
3982
2/2
✓ Branch 0 taken 5294 times.
✓ Branch 1 taken 40 times.
5334 if(Header->zelda_version < 0x193)
3983 {
3984
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
3985 {
3986 return qe_invalid;
3987 }
3988 40 }
3989
3990 //up door
3991
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
3992 {
3993
2/2
✓ Branch 0 taken 192024 times.
✓ Branch 1 taken 48006 times.
240030 for(int32_t k=0; k<4; k++)
3994 {
3995
1/2
✓ Branch 0 taken 192024 times.
✗ Branch 1 not taken.
192024 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
3996 {
3997 return qe_invalid;
3998 }
3999 192024 }
4000 48006 }
4001
4002
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4003 {
4004
2/2
✓ Branch 0 taken 192024 times.
✓ Branch 1 taken 48006 times.
240030 for(int32_t k=0; k<4; k++)
4005 {
4006
1/2
✓ Branch 0 taken 192024 times.
✗ Branch 1 not taken.
192024 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4007 {
4008 return qe_invalid;
4009 }
4010 192024 }
4011 48006 }
4012
4013 //down door
4014
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4015 {
4016
2/2
✓ Branch 0 taken 192024 times.
✓ Branch 1 taken 48006 times.
240030 for(int32_t k=0; k<4; k++)
4017 {
4018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192024 times.
192024 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4019 {
4020 return qe_invalid;
4021 }
4022 192024 }
4023 48006 }
4024
4025
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4026 {
4027
2/2
✓ Branch 0 taken 192024 times.
✓ Branch 1 taken 48006 times.
240030 for(int32_t k=0; k<4; k++)
4028 {
4029
1/2
✓ Branch 0 taken 192024 times.
✗ Branch 1 not taken.
192024 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4030 {
4031 return qe_invalid;
4032 }
4033 192024 }
4034 48006 }
4035
4036 //left door
4037
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4038 {
4039
2/2
✓ Branch 0 taken 288036 times.
✓ Branch 1 taken 48006 times.
336042 for(int32_t k=0; k<6; k++)
4040 {
4041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288036 times.
288036 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4042 {
4043 return qe_invalid;
4044 }
4045 288036 }
4046 48006 }
4047
4048
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4049 {
4050
2/2
✓ Branch 0 taken 288036 times.
✓ Branch 1 taken 48006 times.
336042 for(int32_t k=0; k<6; k++)
4051 {
4052
1/2
✓ Branch 0 taken 288036 times.
✗ Branch 1 not taken.
288036 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4053 {
4054 return qe_invalid;
4055 }
4056 288036 }
4057 48006 }
4058
4059 //right door
4060
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4061 {
4062
2/2
✓ Branch 0 taken 288036 times.
✓ Branch 1 taken 48006 times.
336042 for(int32_t k=0; k<6; k++)
4063 {
4064
1/2
✓ Branch 0 taken 288036 times.
✗ Branch 1 not taken.
288036 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4065 {
4066 return qe_invalid;
4067 }
4068 288036 }
4069 48006 }
4070
4071
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4072 {
4073
2/2
✓ Branch 0 taken 288036 times.
✓ Branch 1 taken 48006 times.
336042 for(int32_t k=0; k<6; k++)
4074 {
4075
1/2
✓ Branch 0 taken 288036 times.
✗ Branch 1 not taken.
288036 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4076 {
4077 return qe_invalid;
4078 }
4079 288036 }
4080 48006 }
4081
4082 //up bomb rubble
4083
2/2
✓ Branch 0 taken 10668 times.
✓ Branch 1 taken 5334 times.
16002 for(int32_t j=0; j<2; j++)
4084 {
4085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10668 times.
10668 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4086 {
4087 return qe_invalid;
4088 }
4089 10668 }
4090
4091
2/2
✓ Branch 0 taken 10668 times.
✓ Branch 1 taken 5334 times.
16002 for(int32_t j=0; j<2; j++)
4092 {
4093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10668 times.
10668 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4094 {
4095 return qe_invalid;
4096 }
4097 10668 }
4098
4099 //down bomb rubble
4100
2/2
✓ Branch 0 taken 10668 times.
✓ Branch 1 taken 5334 times.
16002 for(int32_t j=0; j<2; j++)
4101 {
4102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10668 times.
10668 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4103 {
4104 return qe_invalid;
4105 }
4106 10668 }
4107
4108
2/2
✓ Branch 0 taken 10668 times.
✓ Branch 1 taken 5334 times.
16002 for(int32_t j=0; j<2; j++)
4109 {
4110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10668 times.
10668 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4111 {
4112 return qe_invalid;
4113 }
4114 10668 }
4115
4116 //left bomb rubble
4117
2/2
✓ Branch 0 taken 16002 times.
✓ Branch 1 taken 5334 times.
21336 for(int32_t j=0; j<3; j++)
4118 {
4119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16002 times.
16002 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4120 {
4121 return qe_invalid;
4122 }
4123 16002 }
4124
4125
2/2
✓ Branch 0 taken 16002 times.
✓ Branch 1 taken 5334 times.
21336 for(int32_t j=0; j<3; j++)
4126 {
4127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16002 times.
16002 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4128 {
4129 return qe_invalid;
4130 }
4131 16002 }
4132
4133
2/2
✓ Branch 0 taken 5294 times.
✓ Branch 1 taken 40 times.
5334 if(Header->zelda_version < 0x193)
4134 {
4135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4136 {
4137 return qe_invalid;
4138 }
4139
4140 40 }
4141
4142 //right bomb rubble
4143
2/2
✓ Branch 0 taken 16002 times.
✓ Branch 1 taken 5334 times.
21336 for(int32_t j=0; j<3; j++)
4144 {
4145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16002 times.
16002 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4146 {
4147 return qe_invalid;
4148 }
4149 16002 }
4150
4151
2/2
✓ Branch 0 taken 16002 times.
✓ Branch 1 taken 5334 times.
21336 for(int32_t j=0; j<3; j++)
4152 {
4153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16002 times.
16002 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4154 {
4155 return qe_invalid;
4156 }
4157 16002 }
4158
4159
2/2
✓ Branch 0 taken 5294 times.
✓ Branch 1 taken 40 times.
5334 if(Header->zelda_version < 0x193)
4160 {
4161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4162 {
4163 return qe_invalid;
4164 }
4165 40 }
4166
4167 //walkthrough stuff
4168
2/2
✓ Branch 0 taken 21336 times.
✓ Branch 1 taken 5334 times.
26670 for(int32_t j=0; j<4; j++)
4169 {
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21336 times.
21336 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4171 {
4172 return qe_invalid;
4173 }
4174 21336 }
4175
4176
2/2
✓ Branch 0 taken 21336 times.
✓ Branch 1 taken 5334 times.
26670 for(int32_t j=0; j<4; j++)
4177 {
4178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21336 times.
21336 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4179 {
4180 return qe_invalid;
4181 }
4182 21336 }
4183
4184 //flags
4185
2/2
✓ Branch 0 taken 10668 times.
✓ Branch 1 taken 5334 times.
16002 for(int32_t j=0; j<2; j++)
4186 {
4187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10668 times.
10668 if(!p_getc(&tempDoorComboSet.flags[j],f))
4188 {
4189 return qe_invalid;
4190 }
4191 10668 }
4192
4193
2/2
✓ Branch 0 taken 5294 times.
✓ Branch 1 taken 40 times.
5334 if(Header->zelda_version < 0x193)
4194 {
4195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4196 {
4197 return qe_invalid;
4198 }
4199 40 }
4200
4201
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5320 times.
5334 if (!should_skip)
4202 5320 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4203 5334 }
4204
4205
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 451 times.
452 if (!should_skip)
4206 451 door_combo_set_count=temp_door_combo_set_count;
4207
4208 452 return 0;
4209 470 }
4210
4211 9 int32_t count_dmaps()
4212 {
4213 9 int32_t i=MAXDMAPS-1;
4214 9 bool found=false;
4215
4216
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4217 {
4218
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4219
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4220
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4221 18 found=true;
4222
4223
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4224 {
4225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4226
4227 found=true;
4228 72 }
4229
4230
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4231 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4232 27 found=true;
4233
4234
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4235
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4236
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4237
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4238 18 found=true;
4239
4240 if(!found)
4241 {
4242 i--;
4243 }
4244 }
4245
4246 9 return i+1;
4247 }
4248
4249
4250 9 int32_t count_shops(miscQdata *Misc)
4251 {
4252 9 int32_t i=NUM_SHOPS-1,j;
4253 9 bool found=false;
4254
4255
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4256 {
4257 2229 j=2;
4258
4259
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4260 {
4261
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4262 {
4263 5 found=true;
4264 5 }
4265 else
4266 {
4267 6672 j--;
4268 }
4269 }
4270
4271
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4272 {
4273 found=true;
4274 }
4275
4276
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4277 {
4278 2224 i--;
4279 2224 }
4280 }
4281
4282 9 return i+1;
4283 }
4284
4285 9 int32_t count_infos(miscQdata *Misc)
4286 {
4287 9 int32_t i=255,j;
4288 9 bool found=false;
4289
4290
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4291 {
4292 2229 j=2;
4293
4294
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4295 {
4296
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4297 {
4298 5 found=true;
4299 5 }
4300 else
4301 {
4302 6672 j--;
4303 }
4304 }
4305
4306
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4307 {
4308 found=true;
4309 }
4310
4311
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4312 {
4313 2224 i--;
4314 2224 }
4315 }
4316
4317 9 return i+1;
4318 }
4319
4320 9 int32_t count_warprings(miscQdata *Misc)
4321 {
4322 9 int32_t i=15,j;
4323 9 bool found=false;
4324
4325
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4326 {
4327 49 j=7;
4328
4329
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4330 {
4331
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4332 {
4333 9 found=true;
4334 9 }
4335 else
4336 {
4337 349 j--;
4338 }
4339 }
4340
4341
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4342 {
4343 40 i--;
4344 40 }
4345 }
4346
4347 9 return i+1;
4348 }
4349
4350 9 int32_t count_palcycles(miscQdata *Misc)
4351 {
4352 9 int32_t i=255,j;
4353 9 bool found=false;
4354
4355
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4356 {
4357 2036 j=2;
4358
4359
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4360 {
4361
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4362 {
4363 7 found=true;
4364 7 }
4365 else
4366 {
4367 6087 j--;
4368 }
4369 }
4370
4371
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4372 {
4373 2029 i--;
4374 2029 }
4375 }
4376
4377 9 return i+1;
4378 }
4379
4380 18088 void clear_screen(mapscr *temp_scr)
4381 {
4382 18088 temp_scr->zero_memory();
4383 18088 }
4384
4385 // NOTE: when modifying this, you need to also update:
4386 // readonedmap, readdmaps, and FFScript::read_dmaps
4387 // (and their associated write functions)
4388 3542 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4389 {
4390
2/2
✓ Branch 0 taken 3518 times.
✓ Branch 1 taken 24 times.
3542 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4391
4392 3542 word dmapstoread=0;
4393 3542 dmap tempDMap;
4394
4395 int32_t dummy;
4396 3542 word s_version=0;
4397 byte padding;
4398
4399 char legacy_title[22];
4400
4401
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 469 times.
3542 if (!should_skip)
4402
2/2
✓ Branch 0 taken 240128 times.
✓ Branch 1 taken 469 times.
240597 for(int32_t i=0; i<max_dmaps; i++)
4403 {
4404
1/2
✓ Branch 0 taken 240128 times.
✗ Branch 1 not taken.
240128 DMaps[start_dmap + i].clear();
4405 240128 sprintf(legacy_title," ");
4406 240128 sprintf(DMaps[start_dmap+i].intro," ");
4407 240128 DMaps[start_dmap+i].type |= dmCAVE;
4408 240597 }
4409
4410
3/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 3073 times.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
3542 if (!should_skip && s_version == 21)
4411 Regions = {};
4412
4413 3542 Header->is_z3 = false;
4414
4/4
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 446 times.
✓ Branch 3 taken 24 times.
3542 if(!Header || Header->zelda_version > 0x192)
4415 {
4416 //section version info
4417
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
3518 if(!p_igetw(&s_version,f))
4418 {
4419 return qe_invalid;
4420 }
4421 446 Header->is_z3 = s_version >= 22;
4422
4423 446 FFCore.quest_format[vDMaps] = s_version;
4424
4425
4426
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!read_deprecated_section_cversion(f))
4427 {
4428 return qe_invalid;
4429 }
4430
4431 //section size
4432
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&dummy,f))
4433 {
4434 return qe_invalid;
4435 }
4436
4437 //finally... section data
4438
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&dmapstoread,f))
4439 {
4440 return qe_invalid;
4441 }
4442 446 }
4443 else
4444 {
4445
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4446
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4447 {
4448 18 dmapstoread=32;
4449 18 }
4450
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4451 {
4452 6 dmapstoread=OLDMAXDMAPS;
4453 6 }
4454 else
4455 {
4456 dmapstoread=MAXDMAPS;
4457 }
4458 }
4459
4460
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 387 times.
470 dmapstoread=zc_min(dmapstoread, max_dmaps);
4461
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 387 times.
470 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4462
4463
2/2
✓ Branch 0 taken 215360 times.
✓ Branch 1 taken 470 times.
215830 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4464 {
4465
1/2
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
215360 tempDMap.clear();
4466 215360 sprintf(legacy_title," ");
4467 215360 sprintf(tempDMap.intro," ");
4468
4469
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.map,f))
4470 {
4471 return qe_invalid;
4472 }
4473
4474
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 198144 times.
215360 if(s_version <= 4)
4475 {
4476 byte tempbyte;
4477
4478
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4479 {
4480 return qe_invalid;
4481 }
4482
4483 17216 tempDMap.level=(word)tempbyte;
4484 17216 }
4485 else
4486 {
4487
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_igetw(&tempDMap.level,f))
4488 {
4489 return qe_invalid;
4490 }
4491 }
4492
4493
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.xoff,f))
4494 {
4495 return qe_invalid;
4496 }
4497
4498
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.compass,f))
4499 {
4500 return qe_invalid;
4501 }
4502
4503
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version > 8) // February 2009
4504 {
4505
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_igetw(&tempDMap.color,f))
4506 {
4507 return qe_invalid;
4508 }
4509 198144 }
4510 else
4511 {
4512 byte tempbyte;
4513
4514
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4515 {
4516 return qe_invalid;
4517 }
4518
4519 17216 tempDMap.color = (word)tempbyte;
4520 }
4521
4522
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.midi,f))
4523 {
4524 return qe_invalid;
4525 }
4526
4527
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.cont,f))
4528 {
4529 return qe_invalid;
4530 }
4531
4532
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.type,f))
4533 {
4534 return qe_invalid;
4535 }
4536
4537
4/4
✓ Branch 0 taken 5932 times.
✓ Branch 1 taken 209428 times.
✓ Branch 2 taken 5888 times.
✓ Branch 3 taken 44 times.
221292 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4538
1/2
✓ Branch 0 taken 5932 times.
✗ Branch 1 not taken.
5932 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4539 5888 tempDMap.xoff = 0;
4540
4541
2/2
✓ Branch 0 taken 215360 times.
✓ Branch 1 taken 1722880 times.
1938240 for(int32_t j=0; j<8; j++)
4542 {
4543
2/4
✓ Branch 0 taken 1722880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1722880 times.
✗ Branch 3 not taken.
1722880 if(!p_getc(&tempDMap.grid[j],f))
4544 {
4545 return qe_invalid;
4546 }
4547 1722880 }
4548
4549
5/6
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 213248 times.
215360 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4550 {
4551
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4552 {
4553 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4554 127 }
4555
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4556
4557
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4558 {
4559
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4560
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4561 18 }
4562
4563 //forgotten -DD
4564
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4565 {
4566 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4567 439 }
4568 576 }
4569 else
4570 {
4571
3/4
✓ Branch 0 taken 214784 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
213248 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4572 {
4573 return qe_invalid;
4574 }
4575
4576
2/2
✓ Branch 0 taken 130304 times.
✓ Branch 1 taken 84480 times.
214784 if(s_version<20)
4577 {
4578
2/4
✓ Branch 0 taken 130304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130304 times.
✗ Branch 3 not taken.
130304 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4579 {
4580 return qe_invalid;
4581 }
4582
1/2
✓ Branch 0 taken 130304 times.
✗ Branch 1 not taken.
130304 tempDMap.title.assign(legacy_title);
4583 130304 }
4584 else
4585 {
4586
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_getwstr(&tempDMap.title, f))
4587 {
4588 return qe_invalid;
4589 }
4590 }
4591
4592
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4593 {
4594 return qe_invalid;
4595 }
4596
4597
5/8
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 213248 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
214784 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4598 {
4599 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4600 DMaps[i] = tempDMap;
4601
4602 continue;
4603 }
4604
4605
3/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 213248 times.
214784 if(Header && (Header->zelda_version < 0x193))
4606 {
4607
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4608 {
4609 return qe_invalid;
4610 }
4611 1536 }
4612
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 121600 times.
214784 if ( s_version >= 11 )
4613 {
4614
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4615 {
4616 return qe_invalid;
4617 }
4618 93184 }
4619 else
4620 {
4621
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4622 {
4623 return qe_invalid;
4624 }
4625 }
4626
4627
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getc(&tempDMap.minimap_1_cset,f))
4628 {
4629 return qe_invalid;
4630 }
4631
4632
3/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 213248 times.
214784 if(Header && (Header->zelda_version < 0x193))
4633 {
4634
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4635 {
4636 return qe_invalid;
4637 }
4638 1536 }
4639
4640
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 121600 times.
214784 if ( s_version >= 11 )
4641 {
4642
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4643 {
4644 return qe_invalid;
4645 }
4646 93184 }
4647 else
4648 {
4649
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4650 {
4651 return qe_invalid;
4652 }
4653 }
4654
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getc(&tempDMap.minimap_2_cset,f))
4655 {
4656 return qe_invalid;
4657 }
4658
4659
3/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 213248 times.
214784 if(Header && (Header->zelda_version < 0x193))
4660 {
4661
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4662 {
4663 return qe_invalid;
4664 }
4665 1536 }
4666
4667
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 121600 times.
214784 if ( s_version >= 11 )
4668 {
4669
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4670 {
4671 return qe_invalid;
4672 }
4673 93184 }
4674 else
4675 {
4676
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4677 {
4678 return qe_invalid;
4679 }
4680 }
4681
4682
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getc(&tempDMap.largemap_1_cset,f))
4683 {
4684 return qe_invalid;
4685 }
4686
4687
3/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 213248 times.
214784 if(Header && (Header->zelda_version < 0x193))
4688 {
4689
4690
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4691 {
4692 return qe_invalid;
4693 }
4694 1536 }
4695
4696
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 121600 times.
214784 if ( s_version >= 11 )
4697 {
4698
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4699 {
4700 return qe_invalid;
4701 }
4702 93184 }
4703 else
4704 {
4705
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4706 {
4707 return qe_invalid;
4708 }
4709 }
4710
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getc(&tempDMap.largemap_2_cset,f))
4711 {
4712 return qe_invalid;
4713 }
4714
4715
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4716 {
4717 return qe_invalid;
4718 }
4719 }
4720
4721
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version>1)
4722 {
4723
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_getc(&tempDMap.tmusictrack,f))
4724 {
4725 return qe_invalid;
4726 }
4727
4728
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_getc(&tempDMap.active_subscreen,f))
4729 {
4730 return qe_invalid;
4731 }
4732
4733
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_getc(&tempDMap.passive_subscreen,f))
4734 {
4735 return qe_invalid;
4736 }
4737 198144 }
4738
4739
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version>2)
4740 {
4741 byte di[32];
4742
4743
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!pfread(&di, 32, f)) return qe_invalid;
4744
4745
2/2
✓ Branch 0 taken 50724864 times.
✓ Branch 1 taken 198144 times.
50923008 for(int32_t j=0; j<MAXITEMS; j++)
4746 {
4747
2/2
✓ Branch 0 taken 9207 times.
✓ Branch 1 taken 50715657 times.
50724864 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4748 50715657 else tempDMap.disableditems[j]=0;
4749 50724864 }
4750 198144 }
4751
4752
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version >= 6)
4753 {
4754
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_igetl(&tempDMap.flags,f))
4755 {
4756 return qe_invalid;
4757 }
4758 198144 }
4759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4760 {
4761 char temp;
4762
4763 if(!p_getc(&temp,f))
4764 {
4765 return qe_invalid;
4766 }
4767
4768 tempDMap.flags = temp;
4769 }
4770
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4771 {
4772 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4773 8992 }
4774 else
4775 8224 tempDMap.flags=0;
4776
4777
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version<7)
4778 {
4779
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4780 6146 tempDMap.flags|= dmfVIEWMAP;
4781 17216 }
4782
4783
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version<8)
4784 {
4785
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4786 {
4787
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4788 8050 tempDMap.type |= dmCAVE;
4789 8050 }
4790
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4791 {
4792 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4793 2332 }
4794 17216 }
4795
4796
7/8
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 213248 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 213248 times.
215360 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4797 214784 && (Header->zelda_version < 0x193))
4798 {
4799
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4800 {
4801 return qe_invalid;
4802 }
4803 1536 }
4804
4805
2/2
✓ Branch 0 taken 122176 times.
✓ Branch 1 taken 93184 times.
215360 if(s_version >= 10)
4806 {
4807
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_getc(&tempDMap.sideview,f))
4808 {
4809 return qe_invalid;
4810 }
4811 93184 }
4812
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if(s_version < 10) tempDMap.sideview = 0;
4813
4814 //Dmap Scripts
4815
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if(s_version >= 12)
4816 {
4817
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetw(&tempDMap.script,f))
4818 {
4819 return qe_invalid;
4820 }
4821
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; q++ )
4822 {
4823
2/4
✓ Branch 0 taken 745472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 745472 times.
✗ Branch 3 not taken.
745472 if(!p_igetl(&tempDMap.initD[q],f))
4824 {
4825 return qe_invalid;
4826 }
4827 745472 }
4828 93184 }
4829
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if ( s_version < 12 )
4830 {
4831 122176 tempDMap.script = 0;
4832
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for ( int32_t q = 0; q < 8; q++ )
4833 {
4834 977408 tempDMap.initD[q] = 0;
4835 977408 }
4836 122176 }
4837
4838
2/2
✓ Branch 0 taken 122176 times.
✓ Branch 1 taken 93184 times.
215360 if(s_version >= 13)
4839 {
4840
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; q++ )
4841 {
4842
2/2
✓ Branch 0 taken 48455680 times.
✓ Branch 1 taken 745472 times.
49201152 for ( int32_t w = 0; w < 65; w++ )
4843 {
4844
2/4
✓ Branch 0 taken 48455680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48455680 times.
✗ Branch 3 not taken.
48455680 if(!p_getc(&tempDMap.initD_label[q][w],f))
4845 {
4846 return qe_invalid;
4847 }
4848 48455680 }
4849 745472 }
4850 93184 }
4851
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if ( s_version < 13 )
4852 {
4853 122176 tempDMap.script = 0;
4854
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for ( int32_t q = 0; q < 8; q++ )
4855 {
4856
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for ( int32_t w = 0; w < 65; w++ )
4857 63531520 tempDMap.initD_label[q][w] = 0;
4858 977408 }
4859 122176 }
4860
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if(s_version >= 14)
4861 {
4862
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetw(&tempDMap.active_sub_script,f))
4863 {
4864 return qe_invalid;
4865 }
4866
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetw(&tempDMap.passive_sub_script,f))
4867 {
4868 return qe_invalid;
4869 }
4870
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; ++q )
4871 {
4872
2/4
✓ Branch 0 taken 745472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 745472 times.
✗ Branch 3 not taken.
745472 if(!p_igetl(&tempDMap.sub_initD[q],f))
4873 {
4874 return qe_invalid;
4875 }
4876 745472 }
4877
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for(int32_t q = 0; q < 8; ++q)
4878 {
4879
2/2
✓ Branch 0 taken 48455680 times.
✓ Branch 1 taken 745472 times.
49201152 for ( int32_t w = 0; w < 65; ++w )
4880 {
4881
2/4
✓ Branch 0 taken 48455680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48455680 times.
✗ Branch 3 not taken.
48455680 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
4882 {
4883 return qe_invalid;
4884 }
4885 48455680 }
4886 745472 }
4887 93184 }
4888 else
4889 {
4890 122176 tempDMap.active_sub_script = 0;
4891 122176 tempDMap.passive_sub_script = 0;
4892
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for(int32_t q = 0; q < 8; ++q)
4893 {
4894 977408 tempDMap.sub_initD[q] = 0;
4895
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for(int32_t w = 0; w < 65; ++w)
4896 63531520 tempDMap.sub_initD_label[q][w] = 0;
4897 977408 }
4898 }
4899
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if(s_version >= 15)
4900 {
4901
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetw(&tempDMap.onmap_script,f))
4902 {
4903 return qe_invalid;
4904 }
4905
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; ++q )
4906 {
4907
2/4
✓ Branch 0 taken 745472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 745472 times.
✗ Branch 3 not taken.
745472 if(!p_igetl(&tempDMap.onmap_initD[q],f))
4908 {
4909 return qe_invalid;
4910 }
4911 745472 }
4912
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for(int32_t q = 0; q < 8; ++q)
4913 {
4914
2/2
✓ Branch 0 taken 48455680 times.
✓ Branch 1 taken 745472 times.
49201152 for ( int32_t w = 0; w < 65; ++w )
4915 {
4916
2/4
✓ Branch 0 taken 48455680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48455680 times.
✗ Branch 3 not taken.
48455680 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
4917 {
4918 return qe_invalid;
4919 }
4920 48455680 }
4921 745472 }
4922 93184 }
4923 else
4924 {
4925 122176 tempDMap.onmap_script = 0;
4926
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for(int32_t q = 0; q < 8; ++q)
4927 {
4928 977408 tempDMap.onmap_initD[q] = 0;
4929
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for(int32_t w = 0; w < 65; ++w)
4930 {
4931 63531520 tempDMap.onmap_initD_label[q][w] = 0;
4932 63531520 }
4933 977408 }
4934 }
4935
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if(s_version >= 16)
4936 {
4937
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetw(&tempDMap.mirrorDMap,f))
4938 {
4939 return qe_invalid;
4940 }
4941 93184 }
4942 else
4943 {
4944 122176 tempDMap.mirrorDMap = -1;
4945 }
4946
4947 // Enhanced music loop points
4948
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 130880 times.
215360 if (s_version >= 18)
4949 {
4950
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
4951 {
4952 return qe_invalid;
4953 }
4954
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
4955 {
4956 return qe_invalid;
4957 }
4958
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
4959 {
4960 return qe_invalid;
4961 }
4962
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
4963 {
4964 return qe_invalid;
4965 }
4966 84480 }
4967 else
4968 {
4969 130880 tempDMap.tmusic_loop_start = 0;
4970 130880 tempDMap.tmusic_loop_end = 0;
4971 130880 tempDMap.tmusic_xfade_in = 0;
4972 130880 tempDMap.tmusic_xfade_out = 0;
4973 }
4974
4975
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 130880 times.
215360 if(s_version >= 19)
4976
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if(!p_getc(&tempDMap.overlay_subscreen, f))
4977 return qe_invalid;
4978
4979
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 130880 times.
215360 if (s_version >= 20)
4980 {
4981
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_igetl(&tempDMap.intro_string_id, f))
4982 return qe_invalid;
4983 84480 }
4984 else
4985 130880 tempDMap.intro_string_id = 0;
4986
4987
2/2
✓ Branch 0 taken 201024 times.
✓ Branch 1 taken 14336 times.
215360 if(s_version == 21)
4988 {
4989 static regions_data tmp_rd;
4990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
4991
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 14336 times.
129024 for(int32_t j=0; j<8; j++)
4992 {
4993
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 114688 times.
1032192 for(int32_t k=0; k<8; k++)
4994 {
4995
2/4
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 917504 times.
✗ Branch 3 not taken.
917504 if(!p_getc(&rd.region_ids[j][k],f))
4996 {
4997 return qe_invalid;
4998 }
4999 917504 }
5000 114688 }
5001 14336 }
5002
5003
2/2
✓ Branch 0 taken 215104 times.
✓ Branch 1 taken 256 times.
215360 if (!should_skip)
5004 {
5005
1/2
✓ Branch 0 taken 215104 times.
✗ Branch 1 not taken.
215104 if(loading_tileset_flags & TILESET_CLEARMAPS)
5006 tempDMap.map = 0;
5007
1/2
✓ Branch 0 taken 215104 times.
✗ Branch 1 not taken.
215104 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5008 {
5009 tempDMap.script = 0;
5010 for(int q = 0; q < 8; ++q)
5011 tempDMap.initD[q] = 0;
5012 }
5013
1/2
✓ Branch 0 taken 215104 times.
✗ Branch 1 not taken.
215104 DMaps[i] = tempDMap;
5014 215104 }
5015 215360 }
5016
5017 470 return 0;
5018 6614 }
5019
5020 387 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5021 {
5022 //these are here to bypass compiler warnings about unused arguments
5023 387 Header=Header;
5024
5025 miscQdata temp_misc;
5026 387 word s_version=0;
5027 387 int32_t tempsize=0;
5028 word dummyw;
5029
5030 387 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5031
5032 //section version info
5033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&s_version,f))
5034 {
5035 return qe_invalid;
5036 }
5037
5038 387 FFCore.quest_format[vColours] = s_version;
5039
5040 387 al_trace("Misc Colours section version: %d\n", s_version);
5041
5042
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
5043 {
5044 return qe_invalid;
5045 }
5046
5047
5048 //section size
5049
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&tempsize,f))
5050 {
5051 return qe_invalid;
5052 }
5053
5054 //finally... section data
5055 387 readsize=0;
5056
5057
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.text,f))
5058 {
5059 return qe_invalid;
5060 }
5061
5062
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.caption,f))
5063 {
5064 return qe_invalid;
5065 }
5066
5067
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.overw_bg,f))
5068 {
5069 return qe_invalid;
5070 }
5071
5072
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5073 {
5074 return qe_invalid;
5075 }
5076
5077
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5078 {
5079 return qe_invalid;
5080 }
5081
5082
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.cave_fg,f))
5083 {
5084 return qe_invalid;
5085 }
5086
5087
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.bs_dk,f))
5088 {
5089 return qe_invalid;
5090 }
5091
5092
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.bs_goal,f))
5093 {
5094 return qe_invalid;
5095 }
5096
5097
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.compass_lt,f))
5098 {
5099 return qe_invalid;
5100 }
5101
5102
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.compass_dk,f))
5103 {
5104 return qe_invalid;
5105 }
5106
5107
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5108 {
5109 return qe_invalid;
5110 }
5111
5112
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.triframe_color,f))
5113 {
5114 return qe_invalid;
5115 }
5116
5117
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.hero_dot,f))
5118 {
5119 return qe_invalid;
5120 }
5121
5122
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5123 {
5124 return qe_invalid;
5125 }
5126
5127
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5128 {
5129 return qe_invalid;
5130 }
5131
5132
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5133 {
5134 return qe_invalid;
5135 }
5136
5137
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5138 {
5139 return qe_invalid;
5140 }
5141
5142
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5143 {
5144 return qe_invalid;
5145 }
5146
5147
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5148 {
5149 return qe_invalid;
5150 }
5151
5152
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5153 {
5154 return qe_invalid;
5155 }
5156
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if(s_version < 4)
5157 {
5158
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5159 return qe_invalid;
5160 205 temp_misc.colors.triforce_tile = dummyw;
5161
5162
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5163 return qe_invalid;
5164 205 temp_misc.colors.triframe_tile = dummyw;
5165
5166
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5167 return qe_invalid;
5168 205 temp_misc.colors.overworld_map_tile = dummyw;
5169
5170
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5171 return qe_invalid;
5172 205 temp_misc.colors.dungeon_map_tile = dummyw;
5173
5174
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5175 return qe_invalid;
5176 205 temp_misc.colors.blueframe_tile = dummyw;
5177
5178
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5179 return qe_invalid;
5180 205 temp_misc.colors.HCpieces_tile = dummyw;
5181 205 }
5182
5183
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5184 {
5185 return qe_invalid;
5186 }
5187
5188
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5189 {
5190 return qe_invalid;
5191 }
5192
5193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(s_version < 2)
5194 {
5195 temp_misc.colors.msgtext = 0x01;
5196 }
5197 else
5198 {
5199
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.msgtext, f))
5200 {
5201 return qe_invalid;
5202 }
5203 }
5204
5205
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if ( s_version >= 3 ) //expanded tile pages to 825
5206 {
5207
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5208 {
5209 return qe_invalid;
5210 }
5211
5212
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5213 {
5214 return qe_invalid;
5215 }
5216
5217
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5218 {
5219 return qe_invalid;
5220 }
5221
5222
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5223 {
5224 return qe_invalid;
5225 }
5226
5227
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5228 {
5229 return qe_invalid;
5230 }
5231
5232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5233 {
5234 return qe_invalid;
5235 }
5236 182 }
5237
5238 387 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5239
5240 387 return 0;
5241 387 }
5242
5243 387 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5244 {
5245 miscQdata temp_misc;
5246 387 word s_version=0;
5247 byte icons;
5248 387 int32_t tempsize=0;
5249
5250 387 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5251
5252 //section version info
5253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&s_version,f))
5254 {
5255 return qe_invalid;
5256 }
5257
5258 387 FFCore.quest_format[vIcons] = s_version;
5259
5260
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
5261 {
5262 return qe_invalid;
5263 }
5264
5265
5266 //section size
5267
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&tempsize,f))
5268 {
5269 return qe_invalid;
5270 }
5271
5272 //finally... section data
5273 387 readsize=0;
5274
5275 387 icons=4;
5276
5277
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if ( s_version >= 10 )
5278 {
5279
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<icons; i++)
5280 {
5281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_igetl(&temp_misc.icons[i],f))
5282 {
5283 return qe_invalid;
5284 }
5285 728 }
5286 182 }
5287 else
5288 {
5289
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<icons; i++)
5290 {
5291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(!p_igetw(&temp_misc.icons[i],f))
5292 {
5293 return qe_invalid;
5294 }
5295 820 }
5296 }
5297
5298 387 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5299
5300 387 return 0;
5301 387 }
5302
5303 787 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5304 {
5305
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5306
5307 787 word maxinfos=256;
5308 787 word maxshops=256;
5309 787 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5310 787 word ponds=16, pondsize=72, expansionsize=98*2;
5311 byte tempbyte, padding;
5312 miscQdata temp_misc;
5313 787 word s_version=0;
5314 word swaptmp;
5315 787 int32_t tempsize=0;
5316
5317 787 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5318
5319
2/2
✓ Branch 0 taken 201472 times.
✓ Branch 1 taken 787 times.
202259 for(int32_t i=0; i<maxshops; ++i)
5320 {
5321 201472 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5322 201472 }
5323
5324
2/2
✓ Branch 0 taken 201472 times.
✓ Branch 1 taken 787 times.
202259 for(int32_t i=0; i<maxinfos; ++i)
5325 {
5326 201472 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5327 201472 }
5328
5329 787 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5330
5331
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(Header->zelda_version > 0x192)
5332 {
5333 //section version info
5334
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&s_version,f))
5335 {
5336 return qe_invalid;
5337 }
5338
5339 763 FFCore.quest_format[vMisc] = s_version;
5340
5341
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!read_deprecated_section_cversion(f))
5342 {
5343 return qe_invalid;
5344 }
5345
5346
5347 //section size
5348
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetl(&tempsize,f))
5349 {
5350 return qe_invalid;
5351 }
5352 763 }
5353
5354 //finally... section data
5355 787 readsize=0;
5356
5357 //shops
5358
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(Header->zelda_version > 0x192)
5359 {
5360
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&shops,f))
5361 {
5362 return qe_invalid;
5363 }
5364 763 }
5365
5366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if (shops > NUM_SHOPS)
5367 {
5368 return qe_invalid;
5369 }
5370
5371
2/2
✓ Branch 0 taken 10798 times.
✓ Branch 1 taken 787 times.
11585 for(int32_t i=0; i<shops; i++)
5372 {
5373
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9598 times.
10798 if(s_version > 6)
5374 {
5375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9598 times.
9598 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5376 {
5377 return qe_invalid;
5378 }
5379 9598 }
5380
5381
2/2
✓ Branch 0 taken 32394 times.
✓ Branch 1 taken 10798 times.
43192 for(int32_t j=0; j<3; j++)
5382 {
5383
1/2
✓ Branch 0 taken 32394 times.
✗ Branch 1 not taken.
32394 if(!p_getc(&temp_misc.shop[i].item[j],f))
5384 {
5385 return qe_invalid;
5386 }
5387
5388
2/2
✓ Branch 0 taken 28794 times.
✓ Branch 1 taken 3600 times.
32394 if(s_version < 4)
5389 {
5390 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5391 3600 }
5392 32394 }
5393
5394
2/2
✓ Branch 0 taken 10414 times.
✓ Branch 1 taken 384 times.
10798 if(Header->zelda_version < 0x193)
5395 {
5396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5397 {
5398 return qe_invalid;
5399 }
5400 384 }
5401
5402
2/2
✓ Branch 0 taken 32394 times.
✓ Branch 1 taken 10798 times.
43192 for(int32_t j=0; j<3; j++)
5403 {
5404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32394 times.
32394 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5405 {
5406 return qe_invalid;
5407 }
5408 32394 }
5409
5410
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9598 times.
10798 if(s_version > 3)
5411 {
5412
2/2
✓ Branch 0 taken 28794 times.
✓ Branch 1 taken 9598 times.
38392 for(int32_t j=0; j<3; j++)
5413 {
5414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28794 times.
28794 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5415 return qe_invalid;
5416 28794 }
5417 9598 }
5418
5419 /*
5420 if(s_version < 8)
5421 {
5422 for(int32_t j=0; j<3; j++)
5423 {
5424 (&temp_misc.shop[i].str[j])=0; //initialise.
5425 }
5426 }
5427 */
5428 10798 }
5429
5430 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5431
2/2
✓ Branch 0 taken 201472 times.
✓ Branch 1 taken 787 times.
202259 for(int32_t i=0; i<maxshops; ++i)
5432 {
5433
2/2
✓ Branch 0 taken 402944 times.
✓ Branch 1 taken 201472 times.
604416 for(int32_t j=0; j<3-1; j++)
5434 {
5435
2/2
✓ Branch 0 taken 604416 times.
✓ Branch 1 taken 402944 times.
1007360 for(int32_t k=0; k<2-j; k++)
5436 {
5437
2/2
✓ Branch 0 taken 23434 times.
✓ Branch 1 taken 580982 times.
604416 if(temp_misc.shop[i].hasitem[k]==0)
5438 {
5439 580982 swaptmp = temp_misc.shop[i].item[k];
5440 580982 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5441 580982 temp_misc.shop[i].item[k+1] = swaptmp;
5442 580982 swaptmp = temp_misc.shop[i].price[k];
5443 580982 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5444 580982 temp_misc.shop[i].price[k+1] = swaptmp;
5445 580982 swaptmp = temp_misc.shop[i].hasitem[k];
5446 580982 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5447 580982 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5448 580982 }
5449 604416 }
5450 402944 }
5451 201472 }
5452
5453 //infos
5454
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(Header->zelda_version > 0x192)
5455 {
5456
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&infos,f))
5457 {
5458 return qe_invalid;
5459 }
5460 763 }
5461
5462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if (infos > NUM_INFOS)
5463 {
5464 return qe_invalid;
5465 }
5466
5467
5468
2/2
✓ Branch 0 taken 10104 times.
✓ Branch 1 taken 787 times.
10891 for(int32_t i=0; i<infos; i++)
5469 {
5470
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 9343 times.
10104 if(s_version > 6)
5471 {
5472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9343 times.
9343 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5473 {
5474 return qe_invalid;
5475 }
5476 9343 }
5477
5478
2/2
✓ Branch 0 taken 30312 times.
✓ Branch 1 taken 10104 times.
40416 for(int32_t j=0; j<3; j++)
5479 {
5480
3/4
✓ Branch 0 taken 29448 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
30600 if((Header->zelda_version < 0x192)||
5481
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 29160 times.
29448 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5482 {
5483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5484 {
5485 return qe_invalid;
5486 }
5487
5488 864 temp_misc.info[i].str[j]=tempbyte;
5489 864 }
5490 else
5491 {
5492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29448 times.
29448 if(!p_igetw(&temp_misc.info[i].str[j],f))
5493 {
5494 return qe_invalid;
5495 }
5496 }
5497 30312 }
5498
5499
2/2
✓ Branch 0 taken 9720 times.
✓ Branch 1 taken 384 times.
10104 if(Header->zelda_version < 0x193)
5500 {
5501
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5502 {
5503 return qe_invalid;
5504 }
5505 384 }
5506
5507
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 10008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
10104 if((Header->zelda_version == 0x192)&&(Header->build>145))
5508 {
5509
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5510 {
5511 return qe_invalid;
5512 }
5513 96 }
5514
5515
2/2
✓ Branch 0 taken 30312 times.
✓ Branch 1 taken 10104 times.
40416 for(int32_t j=0; j<3; j++)
5516 {
5517
1/2
✓ Branch 0 taken 30312 times.
✗ Branch 1 not taken.
30312 if(!p_igetw(&temp_misc.info[i].price[j],f))
5518 {
5519 return qe_invalid;
5520 }
5521 30312 }
5522 10104 }
5523
5524 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5525
2/2
✓ Branch 0 taken 201472 times.
✓ Branch 1 taken 787 times.
202259 for(int32_t i=0; i<maxinfos; ++i)
5526 {
5527
2/2
✓ Branch 0 taken 402944 times.
✓ Branch 1 taken 201472 times.
604416 for(int32_t j=0; j<3-1; j++)
5528 {
5529
2/2
✓ Branch 0 taken 604416 times.
✓ Branch 1 taken 402944 times.
1007360 for(int32_t k=0; k<2-j; k++)
5530 {
5531
2/2
✓ Branch 0 taken 11446 times.
✓ Branch 1 taken 592970 times.
604416 if(temp_misc.info[i].str[k]==0)
5532 {
5533 592970 swaptmp = temp_misc.info[i].str[k];
5534 592970 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5535 592970 temp_misc.info[i].str[k+1] = swaptmp;
5536 592970 swaptmp = temp_misc.info[i].price[k];
5537 592970 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5538 592970 temp_misc.info[i].price[k+1] = swaptmp;
5539 592970 }
5540 604416 }
5541 402944 }
5542 201472 }
5543
5544
5545 //warp rings
5546
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 704 times.
787 if(s_version > 5)
5547 704 warprings++;
5548
5549
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(Header->zelda_version > 0x192)
5550 {
5551
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&warprings,f))
5552 {
5553 return qe_invalid;
5554 }
5555
5556
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 433 times.
763 if (warprings > NUM_WARP_RINGS)
5557 {
5558 // return qe_invalid;
5559 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5560 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5561 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5562 433 }
5563 763 }
5564
5565
2/2
✓ Branch 0 taken 8237 times.
✓ Branch 1 taken 787 times.
9024 for(int32_t i=0; i<warprings; i++)
5566 {
5567 // See above comment on the `warprings` range check.
5568 8237 bool keepdata = i < NUM_WARP_RINGS;
5569
5570
2/2
✓ Branch 0 taken 73013 times.
✓ Branch 1 taken 8237 times.
81250 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5571 {
5572
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 64053 times.
73013 if(s_version <= 3)
5573 {
5574
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5575 {
5576 return qe_invalid;
5577 }
5578
5579
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5580 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5581 8960 }
5582 else
5583 {
5584 word tempword;
5585
1/2
✓ Branch 0 taken 64053 times.
✗ Branch 1 not taken.
64053 if(!p_igetw(&tempword,f))
5586 {
5587 return qe_invalid;
5588 }
5589
5590
2/2
✓ Branch 0 taken 7335 times.
✓ Branch 1 taken 56718 times.
64053 if (keepdata)
5591 56718 temp_misc.warp[i].dmap[j] = tempword;
5592 }
5593 73013 }
5594
5595
2/2
✓ Branch 0 taken 73013 times.
✓ Branch 1 taken 8237 times.
81250 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5596 {
5597
1/2
✓ Branch 0 taken 73013 times.
✗ Branch 1 not taken.
73013 if(!p_getc(&tempbyte,f))
5598 {
5599 return qe_invalid;
5600 }
5601
2/2
✓ Branch 0 taken 10527 times.
✓ Branch 1 taken 62486 times.
73013 if (keepdata)
5602 62486 temp_misc.warp[i].scr[j] = tempbyte;
5603 73013 }
5604
5605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8237 times.
8237 if(!p_getc(&tempbyte,f))
5606 {
5607 return qe_invalid;
5608 }
5609
2/2
✓ Branch 0 taken 1214 times.
✓ Branch 1 taken 7023 times.
8237 if (keepdata)
5610 7023 temp_misc.warp[i].size = tempbyte;
5611
5612
2/2
✓ Branch 0 taken 8045 times.
✓ Branch 1 taken 192 times.
8237 if(Header->zelda_version < 0x193)
5613 {
5614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5615 {
5616 return qe_invalid;
5617 }
5618 192 }
5619 8237 }
5620
5621 //palette cycles
5622
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 24 times.
787 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5623 {
5624
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5625 {
5626
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5627 {
5628 18432 temp_misc.cycles[i][j].first=0;
5629 18432 temp_misc.cycles[i][j].count=0;
5630 18432 temp_misc.cycles[i][j].speed=0;
5631 18432 }
5632 6144 }
5633
5634
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5635
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5636 {
5637 18 palcycles=16;
5638 18 }
5639
5640
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5641 {
5642
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5643 {
5644
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5645 {
5646 return qe_invalid;
5647 }
5648
5649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5650 {
5651 return qe_invalid;
5652 }
5653
5654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5655 {
5656 return qe_invalid;
5657 }
5658 5472 }
5659 1824 }
5660 24 }
5661
5662 //Wind warps are now just another warp ring.
5663
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 83 times.
787 if(s_version <= 5)
5664 {
5665
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5666 {
5667
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5668 {
5669 return qe_invalid;
5670 }
5671 59 }
5672
5673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5674 {
5675 return qe_invalid;
5676 }
5677
5678
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5679 {
5680
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5681 {
5682
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5683 {
5684 return qe_invalid;
5685 }
5686
5687 665 temp_misc.warp[8].dmap[i]=tempbyte;
5688 665 }
5689 else
5690 {
5691 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5692 {
5693 return qe_invalid;
5694 }
5695 }
5696
5697
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5698 {
5699 return qe_invalid;
5700 }
5701
5702 665 temp_misc.warp[8].size = 9;
5703
5704
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5705 {
5706 if(!p_getc(&tempbyte,f))
5707 {
5708 return qe_invalid;
5709 }
5710 }
5711 665 }
5712 83 }
5713
5714
5715 //triforce pieces
5716
2/2
✓ Branch 0 taken 6296 times.
✓ Branch 1 taken 787 times.
7083 for(int32_t i=0; i<triforces; i++)
5717 {
5718
1/2
✓ Branch 0 taken 6296 times.
✗ Branch 1 not taken.
6296 if(!p_getc(&temp_misc.triforce[i],f))
5719 {
5720 return qe_invalid;
5721 }
5722 6296 }
5723
5724 //misc color data
5725
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 83 times.
787 if(s_version<3)
5726 {
5727
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5728 {
5729 return qe_invalid;
5730 }
5731
5732
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5733 {
5734 return qe_invalid;
5735 }
5736
5737
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5738 {
5739 return qe_invalid;
5740 }
5741
5742
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5743 {
5744 return qe_invalid;
5745 }
5746
5747
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5748 {
5749 return qe_invalid;
5750 }
5751
5752
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5753 {
5754 return qe_invalid;
5755 }
5756
5757
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5758 {
5759 return qe_invalid;
5760 }
5761
5762
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5763 {
5764 return qe_invalid;
5765 }
5766
5767
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5768 {
5769 return qe_invalid;
5770 }
5771
5772
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5773 {
5774 return qe_invalid;
5775 }
5776
5777
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5778 {
5779 return qe_invalid;
5780 }
5781
5782
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5783 {
5784 return qe_invalid;
5785 }
5786
5787
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5788 {
5789 return qe_invalid;
5790 }
5791
5792
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5793 {
5794 return qe_invalid;
5795 }
5796
5797
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5798 {
5799 return qe_invalid;
5800 }
5801
5802
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5803 {
5804 return qe_invalid;
5805 }
5806
5807
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5808 {
5809 return qe_invalid;
5810 }
5811
5812
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5813 {
5814 return qe_invalid;
5815 }
5816
5817
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5818 {
5819 return qe_invalid;
5820 }
5821
5822
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5823 {
5824 return qe_invalid;
5825 }
5826
5827
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5828 {
5829 return qe_invalid;
5830 }
5831
5832
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5833 {
5834 return qe_invalid;
5835 }
5836
5837
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5838 {
5839 return qe_invalid;
5840 }
5841
5842
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5843 {
5844 return qe_invalid;
5845 }
5846
5847
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5848 {
5849 return qe_invalid;
5850 }
5851
5852
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
5853 {
5854 return qe_invalid;
5855 }
5856
5857
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5858 {
5859 return qe_invalid;
5860 }
5861
5862 83 temp_misc.colors.msgtext = 0x01;
5863
5864
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
5865 {
5866
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
5867 {
5868
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
5869 {
5870 return qe_invalid;
5871 }
5872 168 }
5873 24 }
5874
5875
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
5876 {
5877
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
5878 {
5879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
5880 {
5881 return qe_invalid;
5882 }
5883 1536 }
5884 6 }
5885
5886
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
5887 {
5888 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5889 {
5890 return qe_invalid;
5891 }
5892 }
5893
5894 //save game icons
5895
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
5896
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5897 {
5898 18 icons=3;
5899 18 }
5900
5901
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
5902 {
5903
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
5904 {
5905 return qe_invalid;
5906 }
5907 314 }
5908 83 }
5909
5910
3/4
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
793 if((Header->zelda_version < 0x192)||
5911
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 763 times.
769 ((Header->zelda_version == 0x192)&&(Header->build<30)))
5912 {
5913 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5914
5915 18 return 0;
5916 }
5917
5918 //pond information
5919
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 6 times.
769 if(Header->zelda_version < 0x193)
5920 {
5921
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
5922 {
5923 pondsize=25;
5924 }
5925
5926
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
5927 {
5928
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
5929 {
5930
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
5931 {
5932 return qe_invalid;
5933
5934 }
5935 6912 }
5936 96 }
5937 6 }
5938
5939 //end string
5940
2/4
✓ Branch 0 taken 769 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
775 if((Header->zelda_version < 0x192)||
5941
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 763 times.
769 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5942 {
5943 if(!p_getc(&tempbyte,f))
5944 {
5945 return qe_invalid;
5946 }
5947
5948 temp_misc.endstring=tempbyte;
5949
5950 if(!p_getc(&tempbyte,f))
5951 {
5952 return qe_invalid;
5953 }
5954 }
5955 else
5956 {
5957
1/2
✓ Branch 0 taken 769 times.
✗ Branch 1 not taken.
769 if(!p_igetw(&temp_misc.endstring,f))
5958 {
5959 return qe_invalid;
5960 }
5961 }
5962
5963 //expansion
5964
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 6 times.
769 if(Header->zelda_version < 0x193)
5965 {
5966
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
5967 {
5968 expansionsize=99*2;
5969 }
5970
5971
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
5972 {
5973
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
5974 {
5975 return qe_invalid;
5976 }
5977 1176 }
5978 6 }
5979 //shops v8
5980
5981
5982
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 182 times.
769 if(s_version >= 8)
5983 {
5984
2/2
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 182 times.
2342 for(int32_t i=0; i<shops; i++)
5985 {
5986
2/2
✓ Branch 0 taken 6480 times.
✓ Branch 1 taken 2160 times.
8640 for(int32_t j=0; j<3; j++)
5987 {
5988
1/2
✓ Branch 0 taken 6480 times.
✗ Branch 1 not taken.
6480 if(!p_igetw(&temp_misc.shop[i].str[j],f))
5989 return qe_invalid;
5990 6480 }
5991 2160 }
5992 182 }
5993
5994 769 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
5995 769 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
5996
5997 //v9 includes quest misc[32]
5998 // ... this has been deprecated (2024)
5999
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 182 times.
769 if(s_version >= 9)
6000 {
6001
2/2
✓ Branch 0 taken 5824 times.
✓ Branch 1 taken 182 times.
6006 for ( int32_t q = 0; q < 32; q++ )
6002 {
6003
1/2
✓ Branch 0 taken 5824 times.
✗ Branch 1 not taken.
5824 if(!p_igetl(&temp_misc.questmisc[q],f))
6004 return qe_invalid;
6005 5824 }
6006 // this was string labels
6007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if (pack_fseek(f, 32 * 128))
6008 return qe_invalid;
6009 182 }
6010
6011
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
769 if(s_version >= 11 )
6012 {
6013
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6014 return qe_invalid;
6015 182 }
6016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 587 times.
587 else if(s_version < 11 )
6017 {
6018 587 temp_misc.zscript_last_compiled_version = -1;
6019 587 }
6020
6021 769 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6022
6023
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
769 if(s_version >= 12)
6024 {
6025 byte spr;
6026
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t q = 0; q < sprMAX; ++q)
6027 {
6028
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_getc(&spr,f))
6029 return qe_invalid;
6030 46592 temp_misc.sprites[q] = spr;
6031 46592 }
6032 182 }
6033 else
6034 {
6035 587 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6036 //temp_misc.sprites[sprFALL] = ;
6037 }
6038
6039
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
769 if(s_version >= 13)
6040 {
6041
2/2
✓ Branch 0 taken 11648 times.
✓ Branch 1 taken 182 times.
11830 for(size_t q = 0; q < 64; ++q)
6042 {
6043 11648 bottletype* bt = &(temp_misc.bottle_types[q]);
6044
1/2
✓ Branch 0 taken 11648 times.
✗ Branch 1 not taken.
11648 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6045 return qe_invalid;
6046
2/2
✓ Branch 0 taken 34944 times.
✓ Branch 1 taken 11648 times.
46592 for(size_t j = 0; j < 3; ++j)
6047 {
6048
1/2
✓ Branch 0 taken 34944 times.
✗ Branch 1 not taken.
34944 if (!p_getc(&(bt->counter[j]), f))
6049 return qe_invalid;
6050
1/2
✓ Branch 0 taken 34944 times.
✗ Branch 1 not taken.
34944 if (!p_igetw(&(bt->amount[j]), f))
6051 return qe_invalid;
6052 34944 }
6053
1/2
✓ Branch 0 taken 11648 times.
✗ Branch 1 not taken.
11648 if (!p_getc(&(bt->flags), f))
6054 return qe_invalid;
6055
1/2
✓ Branch 0 taken 11648 times.
✗ Branch 1 not taken.
11648 if (!p_getc(&(bt->next_type), f))
6056 return qe_invalid;
6057 11648 }
6058
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(size_t q = 0; q < 256; ++q)
6059 {
6060 46592 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6061
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6062 return qe_invalid;
6063
2/2
✓ Branch 0 taken 139776 times.
✓ Branch 1 taken 46592 times.
186368 for(size_t j = 0; j < 3; ++j)
6064 {
6065
1/2
✓ Branch 0 taken 139776 times.
✗ Branch 1 not taken.
139776 if (!p_getc(&(bst->fill[j]), f))
6066 return qe_invalid;
6067
1/2
✓ Branch 0 taken 139776 times.
✗ Branch 1 not taken.
139776 if (!p_igetw(&(bst->comb[j]), f))
6068 return qe_invalid;
6069
1/2
✓ Branch 0 taken 139776 times.
✗ Branch 1 not taken.
139776 if (!p_getc(&(bst->cset[j]), f))
6070 return qe_invalid;
6071
1/2
✓ Branch 0 taken 139776 times.
✗ Branch 1 not taken.
139776 if (!p_igetw(&(bst->price[j]), f))
6072 return qe_invalid;
6073
1/2
✓ Branch 0 taken 139776 times.
✗ Branch 1 not taken.
139776 if (!p_igetw(&(bst->str[j]), f))
6074 return qe_invalid;
6075 139776 }
6076 46592 }
6077 182 }
6078 else
6079 {
6080
2/2
✓ Branch 0 taken 37568 times.
✓ Branch 1 taken 587 times.
38155 for(size_t q = 0; q < 64; ++q)
6081 37568 temp_misc.bottle_types[q].clear();
6082
2/2
✓ Branch 0 taken 150272 times.
✓ Branch 1 taken 587 times.
150859 for(size_t q = 0; q < 256; ++q)
6083 150272 temp_misc.bottle_shop_types[q].clear();
6084 }
6085
6086
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
769 if(s_version >= 14)
6087 {
6088 byte msfx;
6089
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t q = 0; q < sfxMAX; ++q)
6090 {
6091
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_getc(&msfx,f))
6092 return qe_invalid;
6093 46592 temp_misc.miscsfx[q] = msfx;
6094 46592 }
6095 182 }
6096 else
6097 {
6098 587 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6099 587 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6100 587 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6101 }
6102
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
769 if(s_version < 15)
6103 {
6104 587 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6105 587 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6106 587 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6107 587 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6108 587 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6109 587 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6110 587 }
6111
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 604 times.
769 if(s_version < 16)
6112 {
6113 604 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6114 604 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6115 604 }
6116
6117
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 768 times.
769 if (!should_skip)
6118 768 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6119
6120 769 return 0;
6121 787 }
6122
6123 extern char *item_string[MAXITEMS];
6124 extern const char *old_item_string[iLast];
6125 extern char *weapon_string[MAXWPNS];
6126 extern const char *old_weapon_string[wLast];
6127
6128 470 int32_t readitems(PACKFILE *f, word version, word build)
6129 {
6130
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 24 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6131
6132 byte padding;
6133 int32_t dummy;
6134 470 word items_to_read=MAXITEMS;
6135 470 itemdata tempitem;
6136 470 word s_version=0;
6137 word dummy_word;
6138
6139
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6 times.
470 if(version < 0x186)
6140 {
6141 6 items_to_read=64;
6142 6 }
6143
6144
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 446 times.
470 if(version > 0x192)
6145 {
6146 446 items_to_read=0;
6147
6148 //section version info
6149
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&s_version,f))
6150 {
6151 return qe_invalid;
6152 }
6153
6154 446 FFCore.quest_format[vItems] = s_version;
6155
6156
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!read_deprecated_section_cversion(f))
6157 {
6158 return qe_invalid;
6159 }
6160
6161 //section size
6162
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy,f))
6163 {
6164 return qe_invalid;
6165 }
6166
6167 //finally... section data
6168
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&items_to_read,f))
6169 {
6170 return qe_invalid;
6171 }
6172
6173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if (items_to_read > MAXITEMS)
6174 {
6175 return qe_invalid;
6176 }
6177 446 }
6178
6179
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 83 times.
470 if(s_version>1)
6180 {
6181
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i=0; i<items_to_read; i++)
6182 {
6183 char tempname[64];
6184
6185
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!pfread(tempname, 64, f))
6186 {
6187 return qe_invalid;
6188 }
6189
6190 99072 item_string[i][0] = '\0';
6191 99072 strncat(item_string[i], tempname, 64 - 1);
6192 99072 }
6193 387 }
6194
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6195 {
6196
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6197 {
6198 20992 reset_itemname(i);
6199 20992 }
6200 82 }
6201
6202
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 469 times.
470 if (!should_skip)
6203
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<MAXITEMS; i++)
6204 {
6205 120064 itemdata& id = itemsbuf[i];
6206 120064 memset(&id, 0, sizeof(itemdata));
6207 120064 id.count=-1;
6208 120064 id.playsound=WAV_SCALE;
6209 120064 reset_itembuf(&id,i);
6210 120533 }
6211
6212
2/2
✓ Branch 0 taken 108194 times.
✓ Branch 1 taken 470 times.
108664 for(int32_t i=0; i<items_to_read; i++)
6213 {
6214 108194 tempitem = itemdata();
6215 108194 reset_itembuf(&tempitem,i);
6216
6217
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 61602 times.
108194 if ( s_version > 35 ) //expanded tiles
6218 {
6219
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.tile,f))
6220 {
6221 return qe_invalid;
6222 }
6223 46592 }
6224 else
6225 {
6226
1/2
✓ Branch 0 taken 61602 times.
✗ Branch 1 not taken.
61602 if(!p_igetw(&tempitem.tile,f))
6227 {
6228 return qe_invalid;
6229 }
6230 }
6231
6232
1/2
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
108194 if(!p_getc(&tempitem.misc_flags,f))
6233 {
6234 return qe_invalid;
6235 }
6236
6237
1/2
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
108194 if(!p_getc(&tempitem.csets,f))
6238 {
6239 return qe_invalid;
6240 }
6241
6242
1/2
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
108194 if(!p_getc(&tempitem.frames,f))
6243 {
6244 return qe_invalid;
6245 }
6246
6247
1/2
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
108194 if(!p_getc(&tempitem.speed,f))
6248 {
6249 return qe_invalid;
6250 }
6251
6252
1/2
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
108194 if(!p_getc(&tempitem.delay,f))
6253 {
6254 return qe_invalid;
6255 }
6256
6257
2/2
✓ Branch 0 taken 103202 times.
✓ Branch 1 taken 4992 times.
108194 if(version < 0x193)
6258 {
6259
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6260 {
6261 return qe_invalid;
6262 }
6263
6264
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6265 {
6266
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6267 256 continue;
6268
6269
3/3
✓ Branch 0 taken 4690 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6270 {
6271 case iShield:
6272 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6273 23 break;
6274
6275 case iMShield:
6276 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6277 23 break;
6278
6279 default:
6280 4690 tempitem.ltm=0;
6281 4690 break;
6282 }
6283
6284 4736 tempitem.count=-1;
6285 4736 tempitem.flags=item_none;
6286 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6287 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6288 4736 tempitem.family=0xFF;
6289 4736 tempitem.playsound=WAV_SCALE;
6290 4736 reset_itembuf(&tempitem,i);
6291
6292 4736 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6293
6294 4736 continue;
6295 }
6296 }
6297
6298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103202 times.
103202 if(!p_igetl(&tempitem.ltm,f))
6299 {
6300 return qe_invalid;
6301 }
6302
6303
1/2
✓ Branch 0 taken 103202 times.
✗ Branch 1 not taken.
103202 if(version < 0x193)
6304 {
6305 for(int32_t q=0; q<12; q++)
6306 {
6307 if(!p_getc(&padding,f))
6308 {
6309 return qe_invalid;
6310 }
6311 }
6312 }
6313
6314
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 4130 times.
103202 if(s_version>1)
6315 {
6316
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 52480 times.
99072 if ( s_version >= 31 )
6317 {
6318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.family,f))
6319 {
6320 return qe_invalid;
6321 }
6322 46592 }
6323 else
6324 {
6325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52480 times.
52480 if(!p_getc(&tempitem.family,f))
6326 {
6327 return qe_invalid;
6328 }
6329 }
6330
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version < 16)
6331 if(tempitem.family == 0xFF)
6332 tempitem.family = itype_misc;
6333
6334
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.fam_type,f))
6335 {
6336 return qe_invalid;
6337 }
6338
6339
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version>5)
6340 {
6341
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 52480 times.
99072 if(s_version>=31)
6342 {
6343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.power,f))
6344 {
6345 return qe_invalid;
6346 }
6347 46592 }
6348 else
6349 {
6350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52480 times.
52480 if(!p_getc(&tempitem.power,f))
6351 {
6352 return qe_invalid;
6353 }
6354 }
6355
6356 //converted flags from 16b to 32b -Z
6357
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version < 41 )
6358 {
6359
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!p_igetw(&tempitem.flags,f))
6360 {
6361 return qe_invalid;
6362 }
6363 52480 }
6364 else
6365 {
6366
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.flags,f))
6367 {
6368 return qe_invalid;
6369 }
6370 }
6371 99072 }
6372 else
6373 {
6374 //tempitem.power = tempitem.fam_type;
6375 char tempchar;
6376
6377 if(!p_getc(&tempchar,f))
6378 {
6379 return qe_invalid;
6380 }
6381
6382 if (tempchar) tempitem.flags |= item_gamedata;
6383 }
6384
6385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetw(&tempitem.script,f))
6386 {
6387 return qe_invalid;
6388 }
6389
6390
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version<=3)
6391 {
6392 if(tempitem.script > NUMSCRIPTITEM)
6393 {
6394 tempitem.script = 0;
6395 }
6396 }
6397
6398
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.count,f))
6399 {
6400 return qe_invalid;
6401 }
6402
6403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetw(&tempitem.amount,f))
6404 {
6405 return qe_invalid;
6406 }
6407
6408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetw(&tempitem.collect_script,f))
6409 {
6410 return qe_invalid;
6411 }
6412
6413
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version<=3)
6414 {
6415 if(tempitem.collect_script > NUMSCRIPTITEM)
6416 {
6417 tempitem.collect_script = 0;
6418 }
6419 }
6420
6421
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetw(&tempitem.setmax,f))
6422 {
6423 return qe_invalid;
6424 }
6425
6426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetw(&tempitem.max,f))
6427 {
6428 return qe_invalid;
6429 }
6430
6431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_getc(&tempitem.playsound,f))
6432 {
6433 return qe_invalid;
6434 }
6435
6436
2/2
✓ Branch 0 taken 792576 times.
✓ Branch 1 taken 99072 times.
891648 for(int32_t j=0; j<8; j++)
6437 {
6438
1/2
✓ Branch 0 taken 792576 times.
✗ Branch 1 not taken.
792576 if(!p_igetl(&tempitem.initiald[j],f))
6439 {
6440 return qe_invalid;
6441 }
6442 792576 }
6443
6444
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 99072 times.
297216 for(int32_t j=0; j<2; j++)
6445 {
6446 byte temp;
6447
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&temp,f))
6448 {
6449 return qe_invalid;
6450 }
6451 198144 }
6452
6453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(s_version>4)
6454 {
6455
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version>5)
6456 {
6457
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn,f))
6458 {
6459 return qe_invalid;
6460 }
6461
6462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_getc(&tempitem.wpn2,f))
6463 {
6464 return qe_invalid;
6465 }
6466
6467
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn3,f))
6468 {
6469 return qe_invalid;
6470 }
6471
6472
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn4,f))
6473 {
6474 return qe_invalid;
6475 }
6476
6477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(s_version>=15)
6478 {
6479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_getc(&tempitem.wpn5,f))
6480 {
6481 return qe_invalid;
6482 }
6483
6484
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn6,f))
6485 {
6486 return qe_invalid;
6487 }
6488
6489
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn7,f))
6490 {
6491 return qe_invalid;
6492 }
6493
6494
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn8,f))
6495 {
6496 return qe_invalid;
6497 }
6498
6499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_getc(&tempitem.wpn9,f))
6500 {
6501 return qe_invalid;
6502 }
6503
6504
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn10,f))
6505 {
6506 return qe_invalid;
6507 }
6508 99072 }
6509
6510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_getc(&tempitem.pickup_hearts,f))
6511 {
6512 return qe_invalid;
6513 }
6514
6515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(s_version<15)
6516 {
6517 if(!p_igetw(&dummy_word,f))
6518 {
6519 return qe_invalid;
6520 }
6521
6522 tempitem.misc1=dummy_word;
6523
6524 if(!p_igetw(&dummy_word,f))
6525 {
6526 return qe_invalid;
6527 }
6528
6529 tempitem.misc2=dummy_word;
6530 }
6531 else
6532 {
6533
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc1,f))
6534 {
6535 return qe_invalid;
6536 }
6537
6538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetl(&tempitem.misc2,f))
6539 {
6540 return qe_invalid;
6541 }
6542
6543 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6544
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version<24)
6545 {
6546 if(tempitem.family==itype_shield)
6547 {
6548 tempitem.misc1|=sh_script;
6549 }
6550 }
6551 }
6552
6553
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if(s_version < 53)
6554 {
6555 byte tempbyte;
6556
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!p_getc(&tempbyte,f))
6557 {
6558 return qe_invalid;
6559 }
6560 52480 tempitem.cost_amount[0] = tempbyte;
6561 52480 }
6562 else
6563 {
6564
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 46592 times.
139776 for(auto q = 0; q < 2; ++q)
6565 {
6566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93184 times.
93184 if(!p_igetw(&tempitem.cost_amount[q],f))
6567 {
6568 return qe_invalid;
6569 }
6570 93184 }
6571 }
6572 99072 }
6573 else
6574 {
6575 char tempchar;
6576
6577 if(!p_getc(&tempchar,f))
6578 {
6579 return qe_invalid;
6580 }
6581
6582 if (tempchar) tempitem.flags |= item_edible;
6583 }
6584
6585 // June 2007: more misc. attributes
6586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(s_version>=12)
6587 {
6588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(s_version<15)
6589 {
6590 if(!p_igetw(&dummy_word,f))
6591 {
6592 return qe_invalid;
6593 }
6594
6595 tempitem.misc3=dummy_word;
6596
6597 if(!p_igetw(&dummy_word,f))
6598 {
6599 return qe_invalid;
6600 }
6601
6602 tempitem.misc4=dummy_word;
6603 }
6604 else
6605 {
6606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetl(&tempitem.misc3,f))
6607 {
6608 return qe_invalid;
6609 }
6610
6611
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc4,f))
6612 {
6613 return qe_invalid;
6614 }
6615
6616
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc5,f))
6617 {
6618 return qe_invalid;
6619 }
6620
6621
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc6,f))
6622 {
6623 return qe_invalid;
6624 }
6625
6626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetl(&tempitem.misc7,f))
6627 {
6628 return qe_invalid;
6629 }
6630
6631
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc8,f))
6632 {
6633 return qe_invalid;
6634 }
6635
6636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetl(&tempitem.misc9,f))
6637 {
6638 return qe_invalid;
6639 }
6640
6641
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc10,f))
6642 {
6643 return qe_invalid;
6644 }
6645 }
6646
6647
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.usesound,f))
6648 {
6649 return qe_invalid;
6650 }
6651
6652
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 52480 times.
99072 if(s_version >= 49)
6653 {
6654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_getc(&tempitem.usesound2,f))
6655 {
6656 return qe_invalid;
6657 }
6658 46592 }
6659 52480 else tempitem.usesound2 = 0;
6660
6661
3/4
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
99072 if(s_version < 50 && tempitem.family == itype_mirror)
6662 {
6663 //Split continue/dmap warp effect/sfx, port for old
6664 tempitem.misc2 = tempitem.misc1;
6665 tempitem.usesound2 = tempitem.usesound;
6666 }
6667 99072 }
6668 99072 }
6669
6670
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6671 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_getc(&tempitem.useweapon,f))
6673 {
6674 return qe_invalid;
6675 }
6676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_getc(&tempitem.usedefense,f))
6677 {
6678 return qe_invalid;
6679 }
6680
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weaprange,f))
6681 {
6682 return qe_invalid;
6683 }
6684
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weapduration,f))
6685 {
6686 return qe_invalid;
6687 }
6688
2/2
✓ Branch 0 taken 465920 times.
✓ Branch 1 taken 46592 times.
512512 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6689 {
6690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 465920 times.
465920 if(!p_igetl(&tempitem.weap_pattern[q],f))
6691 {
6692 return qe_invalid;
6693 }
6694 465920 }
6695 46592 }
6696
6697
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6698 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6699
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.duplicates,f))
6700 {
6701 return qe_invalid;
6702 }
6703
2/2
✓ Branch 0 taken 372736 times.
✓ Branch 1 taken 46592 times.
419328 for ( int32_t q = 0; q < INITIAL_D; q++ )
6704 {
6705
1/2
✓ Branch 0 taken 372736 times.
✗ Branch 1 not taken.
372736 if(!p_igetl(&tempitem.weap_initiald[q],f))
6706 {
6707 return qe_invalid;
6708 }
6709 372736 }
6710
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 46592 times.
139776 for ( int32_t q = 0; q < 2; q++ )
6711 {
6712 byte temp;
6713
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_getc(&temp,f))
6714 {
6715 return qe_invalid;
6716 }
6717 93184 }
6718
6719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_getc(&tempitem.drawlayer,f))
6720 {
6721 return qe_invalid;
6722 }
6723
6724
6725
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.hxofs,f))
6726 {
6727 return qe_invalid;
6728 }
6729
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.hyofs,f))
6730 {
6731 return qe_invalid;
6732 }
6733
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.hxsz,f))
6734 {
6735 return qe_invalid;
6736 }
6737
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.hysz,f))
6738 {
6739 return qe_invalid;
6740 }
6741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.hzsz,f))
6742 {
6743 return qe_invalid;
6744 }
6745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.xofs,f))
6746 {
6747 return qe_invalid;
6748 }
6749
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.yofs,f))
6750 {
6751 return qe_invalid;
6752 }
6753
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weap_hxofs,f))
6754 {
6755 return qe_invalid;
6756 }
6757
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weap_hyofs,f))
6758 {
6759 return qe_invalid;
6760 }
6761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.weap_hxsz,f))
6762 {
6763 return qe_invalid;
6764 }
6765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.weap_hysz,f))
6766 {
6767 return qe_invalid;
6768 }
6769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.weap_hzsz,f))
6770 {
6771 return qe_invalid;
6772 }
6773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.weap_xofs,f))
6774 {
6775 return qe_invalid;
6776 }
6777
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weap_yofs,f))
6778 {
6779 return qe_invalid;
6780 }
6781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetw(&tempitem.weaponscript,f))
6782 {
6783 return qe_invalid;
6784 }
6785
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.wpnsprite,f))
6786 {
6787 return qe_invalid;
6788 }
6789 46592 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6790
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 46592 times.
139776 for(auto q = 0; q < num_cost_tmr; ++q)
6791 {
6792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93184 times.
93184 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6793 {
6794 return qe_invalid;
6795 }
6796 93184 }
6797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 for(auto q = num_cost_tmr; q < 2; ++q)
6798 tempitem.magiccosttimer[q] = 0;
6799 46592 }
6800
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6801 {
6802 //Item Size FLags, TileWidth, TileHeight
6803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.overrideFLAGS,f))
6804 {
6805 return qe_invalid;
6806 }
6807
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.tilew,f))
6808 {
6809 return qe_invalid;
6810 }
6811
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.tileh,f))
6812 {
6813 return qe_invalid;
6814 }
6815 46592 }
6816
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 29 ) //! More new vars.
6817 {
6818 //Item Size FLags, TileWidth, TileHeight
6819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
6820 {
6821 return qe_invalid;
6822 }
6823
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weap_tilew,f))
6824 {
6825 return qe_invalid;
6826 }
6827
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weap_tileh,f))
6828 {
6829 return qe_invalid;
6830 }
6831 46592 }
6832
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 30 ) //! More new vars.
6833 {
6834 //Pickup Type
6835
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.pickup,f))
6836 {
6837 return qe_invalid;
6838 }
6839 46592 }
6840
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 32 ) //! More new vars.
6841 {
6842 //Pickup Type
6843
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetw(&tempitem.pstring,f))
6844 {
6845 return qe_invalid;
6846 }
6847 46592 }
6848
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 33 ) //! More new vars.
6849 {
6850 //Pickup Type
6851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetw(&tempitem.pickup_string_flags,f))
6852 {
6853 return qe_invalid;
6854 }
6855 46592 }
6856
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 34 ) //! cost counter
6857 {
6858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(s_version < 53)
6859 {
6860 if(!p_getc(&tempitem.cost_counter[0],f))
6861 {
6862 return qe_invalid;
6863 }
6864 }
6865 else
6866 {
6867
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 46592 times.
139776 for(auto q = 0; q < 2; ++q)
6868 {
6869
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_getc(&tempitem.cost_counter[q],f))
6870 {
6871 return qe_invalid;
6872 }
6873 93184 }
6874 }
6875 46592 }
6876
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 44 ) //! sprite scripts
6877 {
6878
2/2
✓ Branch 0 taken 372736 times.
✓ Branch 1 taken 46592 times.
419328 for ( int32_t q = 0; q < 8; q++ )
6879 {
6880
2/2
✓ Branch 0 taken 24227840 times.
✓ Branch 1 taken 372736 times.
24600576 for ( int32_t w = 0; w < 65; w++ )
6881 {
6882
1/2
✓ Branch 0 taken 24227840 times.
✗ Branch 1 not taken.
24227840 if(!p_getc(&(tempitem.initD_label[q][w]),f))
6883 {
6884 return qe_invalid;
6885 }
6886 24227840 }
6887
2/2
✓ Branch 0 taken 24227840 times.
✓ Branch 1 taken 372736 times.
24600576 for ( int32_t w = 0; w < 65; w++ )
6888 {
6889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24227840 times.
24227840 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
6890 {
6891 return qe_invalid;
6892 }
6893 24227840 }
6894
2/2
✓ Branch 0 taken 24227840 times.
✓ Branch 1 taken 372736 times.
24600576 for ( int32_t w = 0; w < 65; w++ )
6895 {
6896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24227840 times.
24227840 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
6897 {
6898 return qe_invalid;
6899 }
6900 24227840 }
6901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 372736 times.
372736 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
6902 {
6903 return qe_invalid;
6904 }
6905
6906 372736 }
6907
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 46592 times.
139776 for ( int32_t q = 0; q < 2; q++ )
6908 {
6909 byte temp;
6910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93184 times.
93184 if(!p_getc(&temp,f))
6911 {
6912 return qe_invalid;
6913 }
6914 93184 }
6915 //Pickup Type
6916
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetw(&tempitem.sprite_script,f))
6917 {
6918 return qe_invalid;
6919 }
6920 46592 }
6921
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 48 ) //! pickup flags
6922 {
6923
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_getc(&(tempitem.pickupflag),f))
6924 {
6925 return qe_invalid;
6926 }
6927 46592 }
6928
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 43264 times.
99072 if ( s_version >= 57 )
6929 {
6930 43264 std::string str;
6931
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43264 times.
✓ Branch 2 taken 43264 times.
✗ Branch 3 not taken.
43264 if(!p_getcstr(&str,f))
6932 return qe_invalid;
6933 43264 strncpy(tempitem.display_name,str.c_str(),255);
6934
1/3
✓ Branch 0 taken 43264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
43264 }
6935 99072 }
6936 else
6937 {
6938 4130 tempitem.count=-1;
6939 4130 tempitem.family=itype_misc;
6940 4130 tempitem.flags=item_none;
6941 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6942 4130 tempitem.playsound=WAV_SCALE;
6943 4130 reset_itembuf(&tempitem,i);
6944 }
6945
6946
2/2
✓ Branch 0 taken 60962 times.
✓ Branch 1 taken 42240 times.
103202 if(s_version >= 58)
6947 {
6948
2/2
✓ Branch 0 taken 211200 times.
✓ Branch 1 taken 42240 times.
253440 for(int q = 0; q < WPNSPR_MAX; ++q)
6949 {
6950
1/2
✓ Branch 0 taken 211200 times.
✗ Branch 1 not taken.
211200 if(!p_getc(&tempitem.burnsprs[q],f))
6951 return qe_invalid;
6952
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 209920 times.
211200 if(s_version >= 59)
6953
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_getc(&tempitem.light_rads[q],f))
6954 return qe_invalid;
6955 211200 }
6956 42240 }
6957
6958
2/2
✓ Branch 0 taken 72738 times.
✓ Branch 1 taken 30464 times.
103202 if ( s_version >= 60 )
6959 {
6960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30464 times.
30464 if(!p_getc(&tempitem.pickup_litems,f))
6961 return qe_invalid;
6962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30464 times.
30464 if(!p_igetw(&tempitem.pickup_litem_level,f))
6963 return qe_invalid;
6964 30464 }
6965
6966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103202 times.
103202 if (!should_skip)
6967 {
6968
1/2
✓ Branch 0 taken 103202 times.
✗ Branch 1 not taken.
103202 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
6969 {
6970 tempitem.script = 0;
6971 tempitem.weaponscript = 0;
6972 for(int q = 0; q < 8; ++q)
6973 {
6974 tempitem.initiald[q] = 0;
6975 tempitem.weap_initiald[q] = 0;
6976 }
6977 }
6978 103202 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6979 103202 }
6980 103202 }
6981
6982
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 469 times.
470 if (should_skip)
6983 1 return 0;
6984
6985 //////////////////////////////////////////////////////
6986 // Now do any updates because of new item additions
6987 // (These can't be done above because items_to_read
6988 // might be too low.)
6989 //////////////////////////////////////////////////////
6990
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<MAXITEMS; i++)
6991 {
6992 120064 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
6993
6994 //Account for older quests that didn't have an actual item for the used letter
6995
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 99072 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
120064 if(s_version < 2 && i==iLetterUsed)
6996 {
6997 82 reset_itembuf(&tempitem, iLetterUsed);
6998 82 strcpy(item_string[i],old_item_string[i]);
6999 82 tempitem.tile = itemsbuf[iLetter].tile;
7000 82 tempitem.csets = itemsbuf[iLetter].csets;
7001 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7002 82 tempitem.frames = itemsbuf[iLetter].frames;
7003 82 tempitem.speed = itemsbuf[iLetter].speed;
7004 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7005 82 }
7006
7007
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 3)
7008 {
7009
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7010 {
7011 case iRocsFeather:
7012 case iHoverBoots:
7013 case iSpinScroll:
7014 case iL2SpinScroll:
7015 case iCrossScroll:
7016 case iQuakeScroll:
7017 case iL2QuakeScroll:
7018 case iWhispRing:
7019 case iL2WhispRing:
7020 case iChargeRing:
7021 case iL2ChargeRing:
7022 case iPerilScroll:
7023 case iWalletL3:
7024 case iQuiverL4:
7025 case iBombBagL4:
7026 case iBracelet:
7027 case iL2Bracelet:
7028 case iOldGlove:
7029 case iL2Ladder:
7030 case iWealthMedal:
7031 case iL2WealthMedal:
7032 case iL3WealthMedal:
7033 1804 reset_itembuf(&tempitem, i);
7034 1804 strcpy(item_string[i],old_item_string[i]);
7035 1804 break;
7036
7037 case iSShield:
7038 82 reset_itembuf(&tempitem, i);
7039 82 strcpy(item_string[i],old_item_string[i]);
7040 82 strcpy(item_string[iShield],old_item_string[iShield]);
7041 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7042 82 break;
7043 }
7044 20992 }
7045
7046
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 5)
7047 {
7048
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7049 {
7050 case iHeartRing:
7051 case iL2HeartRing:
7052 case iL3HeartRing:
7053 case iMagicRing:
7054 case iL2MagicRing:
7055 case iL3MagicRing:
7056 case iL4MagicRing:
7057 574 reset_itembuf(&tempitem, i);
7058 574 strcpy(item_string[i],old_item_string[i]);
7059 574 break;
7060 }
7061 20992 }
7062
7063
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7064 {
7065
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7066
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7067
7068
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 328 times.
✓ Branch 12 taken 17302 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7069 {
7070 case iTriforce:
7071 82 tempitem.fam_type=1;
7072 82 break;
7073
7074 case iBigTri:
7075 82 tempitem.fam_type=0;
7076 82 break;
7077
7078 case iBombs:
7079 82 tempitem.fam_type=i_bomb;
7080 82 tempitem.power=4;
7081 82 tempitem.wpn=wBOMB;
7082 82 tempitem.wpn2=wBOOM;
7083 82 tempitem.misc1 = 50;
7084
7085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7086
7087 82 break;
7088
7089 case iSBomb:
7090 82 tempitem.fam_type=i_sbomb;
7091 82 tempitem.power=16;
7092 82 tempitem.wpn=wSBOMB;
7093 82 tempitem.wpn2=wSBOOM;
7094 82 tempitem.misc1 = 50;
7095
7096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7097
7098 82 break;
7099
7100 case iBook:
7101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7102 tempitem.wpn = wFIREMAGIC;
7103
7104 82 break;
7105
7106 case iSArrow:
7107 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7108 82 tempitem.power=4;
7109 82 tempitem.flags|=item_gamedata;
7110 82 tempitem.wpn=wSARROW;
7111 82 break;
7112
7113 case iGArrow:
7114 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7115 82 tempitem.power=8;
7116 82 tempitem.flags|=(item_gamedata|item_flag1);
7117 82 tempitem.wpn=wGARROW;
7118 82 break;
7119
7120 case iBrang:
7121 82 tempitem.power=0;
7122 82 tempitem.wpn=wBRANG;
7123 82 tempitem.misc1=36;
7124 82 break;
7125
7126 case iMBrang:
7127 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7128 82 tempitem.power=0;
7129 82 tempitem.wpn=wMBRANG;
7130 82 break;
7131
7132 case iFBrang:
7133 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7134 82 tempitem.power=2;
7135 82 tempitem.wpn=wFBRANG;
7136 82 break;
7137
7138 case iBoots:
7139 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7140 82 tempitem.power=7;
7141 82 break;
7142
7143 case iWand:
7144 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7145 82 tempitem.power=2;
7146 82 tempitem.wpn=wWAND;
7147 82 tempitem.wpn3=wMAGIC;
7148 82 break;
7149
7150 case iBCandle:
7151 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7152 82 tempitem.power=1;
7153 82 tempitem.flags|=(item_gamedata|item_flag1);
7154 82 tempitem.wpn3=wFIRE;
7155 82 break;
7156
7157 case iRCandle:
7158 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7159 82 tempitem.power=1;
7160 82 tempitem.wpn3=wFIRE;
7161 82 break;
7162
7163 case iSword:
7164 82 tempitem.power=1;
7165 82 tempitem.flags|= item_flag4 |item_flag2;
7166 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7167 82 tempitem.wpn2=wSWORDSLASH;
7168 82 break;
7169
7170 case iWSword:
7171 82 tempitem.power=2;
7172 82 tempitem.flags|= item_flag4 |item_flag2;
7173 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7174 82 tempitem.wpn2=wWSWORDSLASH;
7175 82 break;
7176
7177 case iMSword:
7178 82 tempitem.power=4;
7179 82 tempitem.flags|= item_flag4 |item_flag2;
7180 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7181 82 tempitem.wpn2=wMSWORDSLASH;
7182 82 break;
7183
7184 case iXSword:
7185 82 tempitem.power=8;
7186 82 tempitem.flags|= item_flag4 |item_flag2;
7187 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7188 82 tempitem.wpn2=wXSWORDSLASH;
7189 82 break;
7190
7191 case iDivineProtection:
7192 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7193 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7194 82 tempitem.wpn=wDIVINEPROTECTION1A;
7195 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7196 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7197 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7198 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7199 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7200 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7201 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7202 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7203 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7204 82 tempitem.misc1=512;
7205 82 tempitem.cost_amount[0]=64;
7206 82 break;
7207
7208 case iLens:
7209 82 tempitem.misc1=60;
7210 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7211 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7212 82 break;
7213
7214 case iArrow:
7215 82 tempitem.power=2;
7216 82 tempitem.wpn=wARROW;
7217 82 break;
7218
7219 case iHoverBoots:
7220 82 tempitem.misc1=45;
7221 82 tempitem.wpn=iwHover;
7222 82 break;
7223
7224 case iDivineFire:
7225 82 tempitem.power=8;
7226 82 tempitem.wpn=wDIVINEFIRE1A;
7227 82 tempitem.wpn2=wDIVINEFIRE1B;
7228 82 tempitem.wpn3=wDIVINEFIRES1A;
7229 82 tempitem.wpn4=wDIVINEFIRES1B;
7230 82 tempitem.misc1 = 32;
7231 82 tempitem.misc2 = 200;
7232 82 tempitem.cost_amount[0]=32;
7233 82 break;
7234
7235 case iDivineEscape:
7236 82 tempitem.cost_amount[0]=32;
7237 82 break;
7238
7239 case iHookshot:
7240 82 tempitem.power=0;
7241 82 tempitem.flags&=~item_flag1;
7242 82 tempitem.wpn=wHSHEAD;
7243 82 tempitem.wpn2=wHSCHAIN_H;
7244 82 tempitem.wpn4=wHSHANDLE;
7245 82 tempitem.wpn3=wHSCHAIN_V;
7246 82 tempitem.misc1=50;
7247 82 tempitem.misc2=100;
7248 82 break;
7249
7250 case iLongshot:
7251 82 tempitem.power=0;
7252 82 tempitem.flags&=~item_flag1;
7253 82 tempitem.wpn=wLSHEAD;
7254 82 tempitem.wpn2=wLSCHAIN_H;
7255 82 tempitem.wpn4=wLSHANDLE;
7256 82 tempitem.wpn3=wLSCHAIN_V;
7257 82 tempitem.misc1=99;
7258 82 tempitem.misc2=100;
7259 82 break;
7260
7261 case iHammer:
7262 82 tempitem.power=4;
7263 82 tempitem.wpn=wHAMMER;
7264 82 tempitem.wpn2=iwHammerSmack;
7265 82 break;
7266
7267 case iCByrna:
7268 82 tempitem.power=1;
7269 82 tempitem.wpn=wCBYRNA;
7270 82 tempitem.wpn2=wCBYRNASLASH;
7271 82 tempitem.wpn3=wCBYRNAORB;
7272 82 tempitem.misc1=4;
7273 82 tempitem.misc2=16;
7274 82 tempitem.misc3=1;
7275 82 tempitem.cost_amount[0]=1;
7276 82 break;
7277
7278 case iWhistle:
7279 82 tempitem.wpn=wWIND;
7280 82 tempitem.misc1=3;
7281 82 tempitem.flags|=item_flag1;
7282 82 break;
7283
7284 case iBRing:
7285 82 tempitem.power=2;
7286 82 tempitem.misc1=spBLUE;
7287 82 break;
7288
7289 case iRRing:
7290 82 tempitem.power=4;
7291 82 tempitem.misc1=spRED;
7292 82 break;
7293
7294 case iGRing:
7295 82 tempitem.power=8;
7296 82 tempitem.misc1=spGOLD;
7297 82 break;
7298
7299 case iSpinScroll:
7300 82 tempitem.power = 2;
7301 82 tempitem.misc1 = 1;
7302 82 break;
7303
7304 case iL2SpinScroll:
7305 82 tempitem.family=itype_spinscroll2;
7306 82 tempitem.fam_type=1;
7307 82 tempitem.cost_amount[0]=8;
7308 82 tempitem.power=2;
7309 82 tempitem.misc1 = 20;
7310 82 break;
7311
7312 case iQuakeScroll:
7313 82 tempitem.misc1=0x10;
7314 82 tempitem.misc2=64;
7315 82 break;
7316
7317 case iL2QuakeScroll:
7318 82 tempitem.family=itype_quakescroll2;
7319 82 tempitem.fam_type=1;
7320 82 tempitem.power = 2;
7321 82 tempitem.misc1=0x20;
7322 82 tempitem.misc2=192;
7323 82 tempitem.cost_amount[0]=8;
7324 82 break;
7325
7326 case iChargeRing:
7327 82 tempitem.misc1=64;
7328 82 tempitem.misc2=128;
7329 82 break;
7330
7331 case iL2ChargeRing:
7332 82 tempitem.misc1=32;
7333 82 tempitem.misc2=64;
7334 82 break;
7335
7336 case iOldGlove:
7337 82 tempitem.flags |= item_flag1;
7338
7339 //fallthrough
7340 case iBombBagL4:
7341 case iWalletL3:
7342 case iQuiverL4:
7343 case iBracelet:
7344 410 tempitem.power = 1;
7345 410 break;
7346
7347 case iL2Bracelet:
7348 82 tempitem.power = 2;
7349 82 break;
7350
7351 case iMKey:
7352 82 tempitem.power=0xFF;
7353 82 tempitem.flags |= item_flag1;
7354 82 break;
7355 }
7356 20992 }
7357
7358
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 7)
7359 {
7360
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7361 {
7362 case iStoneAgony:
7363 case iStompBoots:
7364 case iPerilRing:
7365 case iWhimsicalRing:
7366 {
7367 328 reset_itembuf(&tempitem, i);
7368 328 strcpy(item_string[i],old_item_string[i]);
7369 328 break;
7370 }
7371 }
7372 20992 }
7373
7374
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 8) // May 2007: Some corrections.
7375 {
7376
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7377 {
7378 case iMShield:
7379 82 tempitem.misc1|=sh_flame;
7380 82 tempitem.misc2|=sh_fireball|sh_magic;
7381
7382
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7383 {
7384 tempitem.misc2 |= sh_sword;
7385 }
7386
7387 // fallthrough
7388 case iShield:
7389 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7390
7391 // fallthrough
7392 case iSShield:
7393 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7394
7395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7396 {
7397 tempitem.misc2 |= sh_rock;
7398 }
7399
7400 246 break;
7401
7402 case iWhispRing:
7403 82 tempitem.power=1;
7404 82 tempitem.flags|=item_gamedata|item_flag1;
7405 82 tempitem.misc1 = 3;
7406 82 break;
7407
7408 case iL2WhispRing:
7409 82 tempitem.power=0;
7410 82 tempitem.flags|=item_gamedata|item_flag1;
7411 82 tempitem.misc1 = 3;
7412 82 break;
7413
7414 case iL2Ladder:
7415 case iBow:
7416 case iCByrna:
7417 246 tempitem.power = 1;
7418 246 break;
7419 }
7420 20992 }
7421
7422
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 99072 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
120064 if(s_version < 9 && i==iClock)
7423 {
7424 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7425 82 }
7426
7427 //add the misc flag for bomb
7428
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 99072 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
120064 if(s_version < 10 && tempitem.family == itype_bomb)
7429 {
7430 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7431 82 }
7432
7433
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 99072 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
120064 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7434 {
7435 164 tempitem.flags = (tempitem.fam_type ? item_gamedata : item_none);
7436 164 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7437 164 }
7438
7439
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 12) // June 2007: More Misc. attributes.
7440 {
7441
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7442 {
7443 case iFBrang:
7444 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7445
7446 //fallthrough
7447 case iMBrang:
7448 164 tempitem.misc3 |= sh_sword|sh_magic;
7449
7450 //fallthrough
7451 case iHookshot:
7452 case iLongshot:
7453 //fallthrough
7454 328 tempitem.misc3 |= sh_fireball;
7455
7456 case iBrang:
7457 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7458 410 break;
7459 }
7460
7461
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 164 times.
✓ Branch 5 taken 246 times.
✓ Branch 6 taken 246 times.
✓ Branch 7 taken 9313 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 82 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 328 times.
✓ Branch 14 taken 164 times.
✓ Branch 15 taken 9629 times.
20992 switch(tempitem.family)
7462 {
7463 case itype_hoverboots:
7464 82 tempitem.usesound = WAV_ZN1HOVER;
7465 82 break;
7466
7467 case itype_wand:
7468 82 tempitem.usesound = WAV_WAND;
7469 82 break;
7470
7471 case itype_book:
7472 82 tempitem.usesound = WAV_FIRE;
7473 82 break;
7474
7475 case itype_arrow:
7476 246 tempitem.usesound = WAV_ARROW;
7477 246 break;
7478
7479 case itype_hookshot:
7480 164 tempitem.usesound = WAV_HOOKSHOT;
7481 164 break;
7482
7483 case itype_brang:
7484 246 tempitem.usesound = WAV_BRANG;
7485 246 break;
7486
7487 case itype_shield:
7488 246 tempitem.usesound = WAV_CHINK;
7489 246 break;
7490
7491 case itype_sword:
7492 9313 tempitem.usesound = WAV_SWORD;
7493 9313 break;
7494
7495 case itype_whistle:
7496 82 tempitem.usesound = WAV_WHISTLE;
7497 82 break;
7498
7499 case itype_hammer:
7500 82 tempitem.usesound = WAV_HAMMER;
7501 82 break;
7502
7503 case itype_divinefire:
7504 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7505 82 break;
7506
7507 case itype_divineescape:
7508 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7509 82 break;
7510
7511 case itype_divineprotection:
7512 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7513 82 break;
7514
7515 case itype_bomb:
7516 case itype_sbomb:
7517 case itype_quakescroll:
7518 case itype_quakescroll2:
7519 328 tempitem.usesound = WAV_BOMB;
7520 328 break;
7521
7522 case itype_spinscroll:
7523 case itype_spinscroll2:
7524 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7525 164 break;
7526 }
7527 20992 }
7528
7529
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 13) // July 2007
7530 {
7531
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7532 {
7533 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7534 82 tempitem.power = 1;
7535 82 tempitem.flags|=item_flag1;
7536 82 }
7537
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_wand)
7538 82 tempitem.flags|=item_flag1;
7539
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.family == itype_book)
7540 {
7541 82 tempitem.flags|=item_flag1;
7542 82 tempitem.power = 2;
7543 82 }
7544 20992 }
7545
7546
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 14) // August 2007
7547 {
7548
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.family == itype_fairy)
7549 {
7550 164 tempitem.usesound = WAV_SCALE;
7551
7552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
164 if(tempitem.fam_type)
7553 164 tempitem.misc3=50;
7554 164 }
7555
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_potion)
7556 {
7557 164 tempitem.flags |= item_gain_old;
7558 164 }
7559 20992 }
7560
7561
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 17) // November 2007
7562 {
7563
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.family == itype_candle && !tempitem.wpn3)
7564 {
7565 tempitem.wpn3 = wFIRE;
7566 }
7567
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.family == itype_arrow && tempitem.power>4)
7568 {
7569 82 tempitem.flags|=item_flag1;
7570 82 }
7571 20992 }
7572
7573
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 18) // New Year's Eve 2007
7574 {
7575
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7576 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7577
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_bait)
7578 82 tempitem.misc1 = 768; // Frames until it goes
7579
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_triforcepiece)
7580 {
7581
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7582 {
7583 82 tempitem.misc2 = 1; // Cutscene 1
7584 82 tempitem.flags |= item_flag1; // Side Warp Out
7585 82 }
7586 164 }
7587 20992 }
7588
7589
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 19) // January 2008
7590 {
7591
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7592 {
7593
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 2 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7594
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 10 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7595 82 }
7596 20992 }
7597
7598
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 20) // October 2008
7599 {
7600
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7601 {
7602 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7603 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7604 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7605 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7606 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7607 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7608 82 }
7609 20992 }
7610
7611
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 21) // November 2008
7612 {
7613
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7614 {
7615 tempitem.flags &= ~item_unused;
7616
7617 if(tempitem.family == itype_sword ||
7618 tempitem.family == itype_wand ||
7619 tempitem.family == itype_candle ||
7620 tempitem.family == itype_cbyrna)
7621 {
7622 tempitem.flags |= item_flag4;
7623 }
7624 }
7625 20992 }
7626
7627
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 22) // September 2009
7628 {
7629
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7630 {
7631 164 tempitem.misc3 = tempitem.power/2;
7632 164 }
7633 20992 }
7634
7635
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 23) // March 2011
7636 {
7637
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_divinefire)
7638 82 tempitem.wpn5 = wFIRE;
7639
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.family == itype_book)
7640 82 tempitem.wpn2 = wFIRE;
7641 20992 }
7642
7643 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7644 // whether it was or not, and a lot of existing quests depended on the
7645 // incorrect behavior.
7646
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 25) // January 2012
7647 {
7648
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.family == itype_bombbag)
7649 328 tempitem.flags |= item_flag1;
7650
7651
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divinefire)
7652 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7653 20992 }
7654
7655
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7656 {
7657
60/60
✓ Branch 0 taken 17688 times.
✓ Branch 1 taken 859 times.
✓ Branch 2 taken 844 times.
✓ Branch 3 taken 610 times.
✓ Branch 4 taken 332 times.
✓ Branch 5 taken 287 times.
✓ Branch 6 taken 568 times.
✓ Branch 7 taken 623 times.
✓ Branch 8 taken 302 times.
✓ Branch 9 taken 932 times.
✓ Branch 10 taken 907 times.
✓ Branch 11 taken 565 times.
✓ Branch 12 taken 873 times.
✓ Branch 13 taken 568 times.
✓ Branch 14 taken 284 times.
✓ Branch 15 taken 568 times.
✓ Branch 16 taken 300 times.
✓ Branch 17 taken 284 times.
✓ Branch 18 taken 861 times.
✓ Branch 19 taken 287 times.
✓ Branch 20 taken 290 times.
✓ Branch 21 taken 570 times.
✓ Branch 22 taken 260 times.
✓ Branch 23 taken 287 times.
✓ Branch 24 taken 284 times.
✓ Branch 25 taken 284 times.
✓ Branch 26 taken 284 times.
✓ Branch 27 taken 300 times.
✓ Branch 28 taken 286 times.
✓ Branch 29 taken 287 times.
✓ Branch 30 taken 284 times.
✓ Branch 31 taken 289 times.
✓ Branch 32 taken 568 times.
✓ Branch 33 taken 1136 times.
✓ Branch 34 taken 785 times.
✓ Branch 35 taken 284 times.
✓ Branch 36 taken 555 times.
✓ Branch 37 taken 1136 times.
✓ Branch 38 taken 284 times.
✓ Branch 39 taken 284 times.
✓ Branch 40 taken 284 times.
✓ Branch 41 taken 284 times.
✓ Branch 42 taken 284 times.
✓ Branch 43 taken 571 times.
✓ Branch 44 taken 568 times.
✓ Branch 45 taken 284 times.
✓ Branch 46 taken 855 times.
✓ Branch 47 taken 858 times.
✓ Branch 48 taken 1148 times.
✓ Branch 49 taken 284 times.
✓ Branch 50 taken 284 times.
✓ Branch 51 taken 284 times.
✓ Branch 52 taken 284 times.
✓ Branch 53 taken 284 times.
✓ Branch 54 taken 311 times.
✓ Branch 55 taken 10996 times.
✓ Branch 56 taken 2923 times.
✓ Branch 57 taken 857 times.
✓ Branch 58 taken 3317 times.
✓ Branch 59 taken 11233 times.
73472 switch(tempitem.family)
7658 {
7659 case itype_sword:
7660 {
7661 17688 tempitem.flags &= ~(item_flag5);
7662 17688 tempitem.misc3 = 0;
7663 17688 tempitem.misc4 = 0;
7664 17688 tempitem.misc5 = 0;
7665 17688 tempitem.misc6 = 0;
7666 17688 tempitem.misc7 = 0;
7667 17688 tempitem.misc8 = 0;
7668 17688 tempitem.misc9 = 0;
7669 17688 tempitem.misc10 = 0;
7670 17688 tempitem.wpn4 = 0;
7671 17688 tempitem.wpn5 = 0;
7672 17688 tempitem.wpn6 = 0;
7673 17688 tempitem.wpn7 = 0;
7674 17688 tempitem.wpn8 = 0;
7675 17688 tempitem.wpn9 = 0;
7676 17688 tempitem.wpn10 = 0;
7677 17688 break;
7678 }
7679 case itype_brang:
7680 {
7681 859 tempitem.flags &= ~(item_flag4 | item_flag5);
7682 859 tempitem.misc2 = 0;
7683 859 tempitem.misc5 = 0;
7684 859 tempitem.misc6 = 0;
7685 859 tempitem.misc7 = 0;
7686 859 tempitem.misc8 = 0;
7687 859 tempitem.misc9 = 0;
7688 859 tempitem.misc10 = 0;
7689 859 tempitem.wpn4 = 0;
7690 859 tempitem.wpn5 = 0;
7691 859 tempitem.wpn6 = 0;
7692 859 tempitem.wpn7 = 0;
7693 859 tempitem.wpn8 = 0;
7694 859 tempitem.wpn9 = 0;
7695 859 tempitem.wpn10 = 0;
7696 859 break;
7697 }
7698 case itype_arrow:
7699 {
7700 844 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7701 844 tempitem.misc2 = 0;
7702 844 tempitem.misc3 = 0;
7703 844 tempitem.misc4 = 0;
7704 844 tempitem.misc5 = 0;
7705 844 tempitem.misc6 = 0;
7706 844 tempitem.misc7 = 0;
7707 844 tempitem.misc8 = 0;
7708 844 tempitem.misc9 = 0;
7709 844 tempitem.misc10 = 0;
7710 844 tempitem.wpn4 = 0;
7711 844 tempitem.wpn5 = 0;
7712 844 tempitem.wpn6 = 0;
7713 844 tempitem.wpn7 = 0;
7714 844 tempitem.wpn8 = 0;
7715 844 tempitem.wpn9 = 0;
7716 844 tempitem.wpn10 = 0;
7717 844 break;
7718 }
7719 case itype_candle:
7720 {
7721 610 tempitem.flags &= ~ (item_flag3 | item_flag5);
7722 610 tempitem.misc1 = 0;
7723 610 tempitem.misc2 = 0;
7724 610 tempitem.misc3 = 0;
7725 610 tempitem.misc4 = 0;
7726 610 tempitem.misc5 = 0;
7727 610 tempitem.misc6 = 0;
7728 610 tempitem.misc7 = 0;
7729 610 tempitem.misc8 = 0;
7730 610 tempitem.misc9 = 0;
7731 610 tempitem.misc10 = 0;
7732 610 tempitem.wpn4 = 0;
7733 610 tempitem.wpn5 = 0;
7734 610 tempitem.wpn6 = 0;
7735 610 tempitem.wpn7 = 0;
7736 610 tempitem.wpn8 = 0;
7737 610 tempitem.wpn9 = 0;
7738 610 tempitem.wpn10 = 0;
7739 610 break;
7740 }
7741 case itype_whistle:
7742 {
7743 332 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7744 332 tempitem.misc3 = 0;
7745 332 tempitem.misc4 = 0;
7746 332 tempitem.misc5 = 0;
7747 332 tempitem.misc6 = 0;
7748 332 tempitem.misc7 = 0;
7749 332 tempitem.misc8 = 0;
7750 332 tempitem.misc9 = 0;
7751 332 tempitem.misc10 = 0;
7752 332 tempitem.wpn2 = 0;
7753 332 tempitem.wpn3 = 0;
7754 332 tempitem.wpn4 = 0;
7755 332 tempitem.wpn5 = 0;
7756 332 tempitem.wpn6 = 0;
7757 332 tempitem.wpn7 = 0;
7758 332 tempitem.wpn8 = 0;
7759 332 tempitem.wpn9 = 0;
7760 332 tempitem.wpn10 = 0;
7761 332 break;
7762 }
7763 case itype_bait:
7764 {
7765 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7766 287 tempitem.misc2 = 0;
7767 287 tempitem.misc3 = 0;
7768 287 tempitem.misc4 = 0;
7769 287 tempitem.misc5 = 0;
7770 287 tempitem.misc6 = 0;
7771 287 tempitem.misc7 = 0;
7772 287 tempitem.misc8 = 0;
7773 287 tempitem.misc9 = 0;
7774 287 tempitem.misc10 = 0;
7775 287 tempitem.wpn2 = 0;
7776 287 tempitem.wpn3 = 0;
7777 287 tempitem.wpn4 = 0;
7778 287 tempitem.wpn5 = 0;
7779 287 tempitem.wpn6 = 0;
7780 287 tempitem.wpn7 = 0;
7781 287 tempitem.wpn8 = 0;
7782 287 tempitem.wpn9 = 0;
7783 287 tempitem.wpn10 = 0;
7784 287 break;
7785 }
7786 case itype_letter:
7787 {
7788 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7789 568 tempitem.misc1 = 0;
7790 568 tempitem.misc2 = 0;
7791 568 tempitem.misc3 = 0;
7792 568 tempitem.misc4 = 0;
7793 568 tempitem.misc5 = 0;
7794 568 tempitem.misc6 = 0;
7795 568 tempitem.misc7 = 0;
7796 568 tempitem.misc8 = 0;
7797 568 tempitem.misc9 = 0;
7798 568 tempitem.misc10 = 0;
7799 568 tempitem.wpn = 0;
7800 568 tempitem.wpn2 = 0;
7801 568 tempitem.wpn3 = 0;
7802 568 tempitem.wpn4 = 0;
7803 568 tempitem.wpn5 = 0;
7804 568 tempitem.wpn6 = 0;
7805 568 tempitem.wpn7 = 0;
7806 568 tempitem.wpn8 = 0;
7807 568 tempitem.wpn9 = 0;
7808 568 tempitem.wpn10 = 0;
7809 568 break;
7810 }
7811 case itype_potion:
7812 {
7813 623 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
7814 623 tempitem.misc3 = 0;
7815 623 tempitem.misc4 = 0;
7816 623 tempitem.misc5 = 0;
7817 623 tempitem.misc6 = 0;
7818 623 tempitem.misc7 = 0;
7819 623 tempitem.misc8 = 0;
7820 623 tempitem.misc9 = 0;
7821 623 tempitem.misc10 = 0;
7822 623 tempitem.wpn = 0;
7823 623 tempitem.wpn2 = 0;
7824 623 tempitem.wpn3 = 0;
7825 623 tempitem.wpn4 = 0;
7826 623 tempitem.wpn5 = 0;
7827 623 tempitem.wpn6 = 0;
7828 623 tempitem.wpn7 = 0;
7829 623 tempitem.wpn8 = 0;
7830 623 tempitem.wpn9 = 0;
7831 623 tempitem.wpn10 = 0;
7832 623 break;
7833 }
7834 case itype_wand:
7835 {
7836 302 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
7837 302 tempitem.misc1 = 0;
7838 302 tempitem.misc2 = 0;
7839 302 tempitem.misc3 = 0;
7840 302 tempitem.misc4 = 0;
7841 302 tempitem.misc5 = 0;
7842 302 tempitem.misc6 = 0;
7843 302 tempitem.misc7 = 0;
7844 302 tempitem.misc8 = 0;
7845 302 tempitem.misc9 = 0;
7846 302 tempitem.misc10 = 0;
7847 302 tempitem.wpn4 = 0;
7848 302 tempitem.wpn5 = 0;
7849 302 tempitem.wpn6 = 0;
7850 302 tempitem.wpn7 = 0;
7851 302 tempitem.wpn8 = 0;
7852 302 tempitem.wpn9 = 0;
7853 302 tempitem.wpn10 = 0;
7854 302 break;
7855 }
7856 case itype_ring:
7857 {
7858 932 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7859 932 tempitem.misc2 = 0;
7860 932 tempitem.misc3 = 0;
7861 932 tempitem.misc4 = 0;
7862 932 tempitem.misc5 = 0;
7863 932 tempitem.misc6 = 0;
7864 932 tempitem.misc7 = 0;
7865 932 tempitem.misc8 = 0;
7866 932 tempitem.misc9 = 0;
7867 932 tempitem.misc10 = 0;
7868 932 tempitem.wpn = 0;
7869 932 tempitem.wpn2 = 0;
7870 932 tempitem.wpn3 = 0;
7871 932 tempitem.wpn4 = 0;
7872 932 tempitem.wpn5 = 0;
7873 932 tempitem.wpn6 = 0;
7874 932 tempitem.wpn7 = 0;
7875 932 tempitem.wpn8 = 0;
7876 932 tempitem.wpn9 = 0;
7877 932 tempitem.wpn10 = 0;
7878 932 break;
7879 }
7880 case itype_wallet:
7881 {
7882 907 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7883 907 tempitem.misc3 = 0;
7884 907 tempitem.misc4 = 0;
7885 907 tempitem.misc5 = 0;
7886 907 tempitem.misc6 = 0;
7887 907 tempitem.misc7 = 0;
7888 907 tempitem.misc8 = 0;
7889 907 tempitem.misc9 = 0;
7890 907 tempitem.misc10 = 0;
7891 907 tempitem.wpn = 0;
7892 907 tempitem.wpn2 = 0;
7893 907 tempitem.wpn3 = 0;
7894 907 tempitem.wpn4 = 0;
7895 907 tempitem.wpn5 = 0;
7896 907 tempitem.wpn6 = 0;
7897 907 tempitem.wpn7 = 0;
7898 907 tempitem.wpn8 = 0;
7899 907 tempitem.wpn9 = 0;
7900 907 tempitem.wpn10 = 0;
7901 907 break;
7902 }
7903 case itype_amulet:
7904 {
7905 565 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7906 565 tempitem.misc1 = 0;
7907 565 tempitem.misc2 = 0;
7908 565 tempitem.misc3 = 0;
7909 565 tempitem.misc4 = 0;
7910 565 tempitem.misc5 = 0;
7911 565 tempitem.misc6 = 0;
7912 565 tempitem.misc7 = 0;
7913 565 tempitem.misc8 = 0;
7914 565 tempitem.misc9 = 0;
7915 565 tempitem.misc10 = 0;
7916 565 tempitem.wpn = 0;
7917 565 tempitem.wpn2 = 0;
7918 565 tempitem.wpn3 = 0;
7919 565 tempitem.wpn4 = 0;
7920 565 tempitem.wpn5 = 0;
7921 565 tempitem.wpn6 = 0;
7922 565 tempitem.wpn7 = 0;
7923 565 tempitem.wpn8 = 0;
7924 565 tempitem.wpn9 = 0;
7925 565 tempitem.wpn10 = 0;
7926 565 break;
7927 }
7928 case itype_shield:
7929 {
7930 873 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7931 873 tempitem.misc3 = 0;
7932 873 tempitem.misc4 = 0;
7933 873 tempitem.misc5 = 0;
7934 873 tempitem.misc6 = 0;
7935 873 tempitem.misc7 = 0;
7936 873 tempitem.misc8 = 0;
7937 873 tempitem.misc9 = 0;
7938 873 tempitem.misc10 = 0;
7939 873 tempitem.wpn = 0;
7940 873 tempitem.wpn2 = 0;
7941 873 tempitem.wpn3 = 0;
7942 873 tempitem.wpn4 = 0;
7943 873 tempitem.wpn5 = 0;
7944 873 tempitem.wpn6 = 0;
7945 873 tempitem.wpn7 = 0;
7946 873 tempitem.wpn8 = 0;
7947 873 tempitem.wpn9 = 0;
7948 873 tempitem.wpn10 = 0;
7949 873 break;
7950 }
7951 case itype_bow:
7952 {
7953 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7954 568 tempitem.misc1 = 0;
7955 568 tempitem.misc2 = 0;
7956 568 tempitem.misc3 = 0;
7957 568 tempitem.misc4 = 0;
7958 568 tempitem.misc5 = 0;
7959 568 tempitem.misc6 = 0;
7960 568 tempitem.misc7 = 0;
7961 568 tempitem.misc8 = 0;
7962 568 tempitem.misc9 = 0;
7963 568 tempitem.misc10 = 0;
7964 568 tempitem.wpn = 0;
7965 568 tempitem.wpn2 = 0;
7966 568 tempitem.wpn3 = 0;
7967 568 tempitem.wpn4 = 0;
7968 568 tempitem.wpn5 = 0;
7969 568 tempitem.wpn6 = 0;
7970 568 tempitem.wpn7 = 0;
7971 568 tempitem.wpn8 = 0;
7972 568 tempitem.wpn9 = 0;
7973 568 tempitem.wpn10 = 0;
7974 568 break;
7975 }
7976 case itype_raft:
7977 {
7978 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7979 284 tempitem.misc1 = 0;
7980 284 tempitem.misc2 = 0;
7981 284 tempitem.misc3 = 0;
7982 284 tempitem.misc4 = 0;
7983 284 tempitem.misc5 = 0;
7984 284 tempitem.misc6 = 0;
7985 284 tempitem.misc7 = 0;
7986 284 tempitem.misc8 = 0;
7987 284 tempitem.misc9 = 0;
7988 284 tempitem.misc10 = 0;
7989 284 tempitem.wpn = 0;
7990 284 tempitem.wpn2 = 0;
7991 284 tempitem.wpn3 = 0;
7992 284 tempitem.wpn4 = 0;
7993 284 tempitem.wpn5 = 0;
7994 284 tempitem.wpn6 = 0;
7995 284 tempitem.wpn7 = 0;
7996 284 tempitem.wpn8 = 0;
7997 284 tempitem.wpn9 = 0;
7998 284 tempitem.wpn10 = 0;
7999 284 break;
8000 }
8001 case itype_ladder:
8002 {
8003 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8004 568 tempitem.misc1 = 0;
8005 568 tempitem.misc2 = 0;
8006 568 tempitem.misc3 = 0;
8007 568 tempitem.misc4 = 0;
8008 568 tempitem.misc5 = 0;
8009 568 tempitem.misc6 = 0;
8010 568 tempitem.misc7 = 0;
8011 568 tempitem.misc8 = 0;
8012 568 tempitem.misc9 = 0;
8013 568 tempitem.misc10 = 0;
8014 568 tempitem.wpn = 0;
8015 568 tempitem.wpn2 = 0;
8016 568 tempitem.wpn3 = 0;
8017 568 tempitem.wpn4 = 0;
8018 568 tempitem.wpn5 = 0;
8019 568 tempitem.wpn6 = 0;
8020 568 tempitem.wpn7 = 0;
8021 568 tempitem.wpn8 = 0;
8022 568 tempitem.wpn9 = 0;
8023 568 tempitem.wpn10 = 0;
8024 568 break;
8025 }
8026 case itype_book:
8027 {
8028 300 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8029 300 tempitem.misc1 = 0;
8030 300 tempitem.misc2 = 0;
8031 300 tempitem.misc3 = 0;
8032 300 tempitem.misc4 = 0;
8033 300 tempitem.misc5 = 0;
8034 300 tempitem.misc6 = 0;
8035 300 tempitem.misc7 = 0;
8036 300 tempitem.misc8 = 0;
8037 300 tempitem.misc9 = 0;
8038 300 tempitem.misc10 = 0;
8039 300 tempitem.wpn3 = 0;
8040 300 tempitem.wpn4 = 0;
8041 300 tempitem.wpn5 = 0;
8042 300 tempitem.wpn6 = 0;
8043 300 tempitem.wpn7 = 0;
8044 300 tempitem.wpn8 = 0;
8045 300 tempitem.wpn9 = 0;
8046 300 tempitem.wpn10 = 0;
8047 300 break;
8048 }
8049 case itype_magickey:
8050 {
8051 284 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8052 284 tempitem.misc1 = 0;
8053 284 tempitem.misc2 = 0;
8054 284 tempitem.misc3 = 0;
8055 284 tempitem.misc4 = 0;
8056 284 tempitem.misc5 = 0;
8057 284 tempitem.misc6 = 0;
8058 284 tempitem.misc7 = 0;
8059 284 tempitem.misc8 = 0;
8060 284 tempitem.misc9 = 0;
8061 284 tempitem.misc10 = 0;
8062 284 tempitem.wpn = 0;
8063 284 tempitem.wpn2 = 0;
8064 284 tempitem.wpn3 = 0;
8065 284 tempitem.wpn4 = 0;
8066 284 tempitem.wpn5 = 0;
8067 284 tempitem.wpn6 = 0;
8068 284 tempitem.wpn7 = 0;
8069 284 tempitem.wpn8 = 0;
8070 284 tempitem.wpn9 = 0;
8071 284 tempitem.wpn10 = 0;
8072 284 break;
8073 }
8074 case itype_bracelet:
8075 {
8076 861 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8077 861 tempitem.misc1 = 0;
8078 861 tempitem.misc2 = 0;
8079 861 tempitem.misc3 = 0;
8080 861 tempitem.misc4 = 0;
8081 861 tempitem.misc5 = 0;
8082 861 tempitem.misc6 = 0;
8083 861 tempitem.misc7 = 0;
8084 861 tempitem.misc8 = 0;
8085 861 tempitem.misc9 = 0;
8086 861 tempitem.misc10 = 0;
8087 861 tempitem.wpn = 0;
8088 861 tempitem.wpn2 = 0;
8089 861 tempitem.wpn3 = 0;
8090 861 tempitem.wpn4 = 0;
8091 861 tempitem.wpn5 = 0;
8092 861 tempitem.wpn6 = 0;
8093 861 tempitem.wpn7 = 0;
8094 861 tempitem.wpn8 = 0;
8095 861 tempitem.wpn9 = 0;
8096 861 tempitem.wpn10 = 0;
8097 861 break;
8098 }
8099 case itype_flippers:
8100 {
8101 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8102 287 tempitem.misc1 = 0;
8103 287 tempitem.misc2 = 0;
8104 287 tempitem.misc3 = 0;
8105 287 tempitem.misc4 = 0;
8106 287 tempitem.misc5 = 0;
8107 287 tempitem.misc6 = 0;
8108 287 tempitem.misc7 = 0;
8109 287 tempitem.misc8 = 0;
8110 287 tempitem.misc9 = 0;
8111 287 tempitem.misc10 = 0;
8112 287 tempitem.wpn = 0;
8113 287 tempitem.wpn2 = 0;
8114 287 tempitem.wpn3 = 0;
8115 287 tempitem.wpn4 = 0;
8116 287 tempitem.wpn5 = 0;
8117 287 tempitem.wpn6 = 0;
8118 287 tempitem.wpn7 = 0;
8119 287 tempitem.wpn8 = 0;
8120 287 tempitem.wpn9 = 0;
8121 287 tempitem.wpn10 = 0;
8122 287 break;
8123 }
8124 case itype_boots:
8125 {
8126 290 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8127 290 tempitem.misc1 = 0;
8128 290 tempitem.misc2 = 0;
8129 290 tempitem.misc3 = 0;
8130 290 tempitem.misc4 = 0;
8131 290 tempitem.misc5 = 0;
8132 290 tempitem.misc6 = 0;
8133 290 tempitem.misc7 = 0;
8134 290 tempitem.misc8 = 0;
8135 290 tempitem.misc9 = 0;
8136 290 tempitem.misc10 = 0;
8137 290 tempitem.wpn = 0;
8138 290 tempitem.wpn2 = 0;
8139 290 tempitem.wpn3 = 0;
8140 290 tempitem.wpn4 = 0;
8141 290 tempitem.wpn5 = 0;
8142 290 tempitem.wpn6 = 0;
8143 290 tempitem.wpn7 = 0;
8144 290 tempitem.wpn8 = 0;
8145 290 tempitem.wpn9 = 0;
8146 290 tempitem.wpn10 = 0;
8147 290 break;
8148 }
8149 case itype_hookshot:
8150 {
8151 570 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8152 570 tempitem.misc5 = 0;
8153 570 tempitem.misc6 = 0;
8154 570 tempitem.misc7 = 0;
8155 570 tempitem.misc8 = 0;
8156 570 tempitem.misc9 = 0;
8157 570 tempitem.misc10 = 0;
8158 570 tempitem.wpn5 = 0;
8159 570 tempitem.wpn6 = 0;
8160 570 tempitem.wpn7 = 0;
8161 570 tempitem.wpn8 = 0;
8162 570 tempitem.wpn9 = 0;
8163 570 tempitem.wpn10 = 0;
8164 570 break;
8165 }
8166 case itype_lens:
8167 {
8168 260 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8169 260 tempitem.misc2 = 0;
8170 260 tempitem.misc3 = 0;
8171 260 tempitem.misc4 = 0;
8172 260 tempitem.misc5 = 0;
8173 260 tempitem.misc6 = 0;
8174 260 tempitem.misc7 = 0;
8175 260 tempitem.misc8 = 0;
8176 260 tempitem.misc9 = 0;
8177 260 tempitem.misc10 = 0;
8178 260 tempitem.wpn = 0;
8179 260 tempitem.wpn2 = 0;
8180 260 tempitem.wpn3 = 0;
8181 260 tempitem.wpn4 = 0;
8182 260 tempitem.wpn5 = 0;
8183 260 tempitem.wpn6 = 0;
8184 260 tempitem.wpn7 = 0;
8185 260 tempitem.wpn8 = 0;
8186 260 tempitem.wpn9 = 0;
8187 260 tempitem.wpn10 = 0;
8188 260 break;
8189 }
8190 case itype_hammer:
8191 {
8192 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8193 287 tempitem.misc1 = 0;
8194 287 tempitem.misc2 = 0;
8195 287 tempitem.misc3 = 0;
8196 287 tempitem.misc4 = 0;
8197 287 tempitem.misc5 = 0;
8198 287 tempitem.misc6 = 0;
8199 287 tempitem.misc7 = 0;
8200 287 tempitem.misc8 = 0;
8201 287 tempitem.misc9 = 0;
8202 287 tempitem.misc10 = 0;
8203 287 tempitem.wpn3 = 0;
8204 287 tempitem.wpn4 = 0;
8205 287 tempitem.wpn5 = 0;
8206 287 tempitem.wpn6 = 0;
8207 287 tempitem.wpn7 = 0;
8208 287 tempitem.wpn8 = 0;
8209 287 tempitem.wpn9 = 0;
8210 287 tempitem.wpn10 = 0;
8211 287 break;
8212 }
8213 case itype_divinefire:
8214 {
8215 284 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8216 284 tempitem.misc3 = 0;
8217 284 tempitem.misc4 = 0;
8218 284 tempitem.misc5 = 0;
8219 284 tempitem.misc6 = 0;
8220 284 tempitem.misc7 = 0;
8221 284 tempitem.misc8 = 0;
8222 284 tempitem.misc9 = 0;
8223 284 tempitem.misc10 = 0;
8224 284 tempitem.wpn6 = 0;
8225 284 tempitem.wpn7 = 0;
8226 284 tempitem.wpn8 = 0;
8227 284 tempitem.wpn9 = 0;
8228 284 tempitem.wpn10 = 0;
8229 284 break;
8230 }
8231 case itype_divineescape:
8232 {
8233 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8234 284 tempitem.misc2 = 0;
8235 284 tempitem.misc3 = 0;
8236 284 tempitem.misc4 = 0;
8237 284 tempitem.misc5 = 0;
8238 284 tempitem.misc6 = 0;
8239 284 tempitem.misc7 = 0;
8240 284 tempitem.misc8 = 0;
8241 284 tempitem.misc9 = 0;
8242 284 tempitem.misc10 = 0;
8243 284 tempitem.wpn = 0;
8244 284 tempitem.wpn2 = 0;
8245 284 tempitem.wpn3 = 0;
8246 284 tempitem.wpn4 = 0;
8247 284 tempitem.wpn5 = 0;
8248 284 tempitem.wpn6 = 0;
8249 284 tempitem.wpn7 = 0;
8250 284 tempitem.wpn8 = 0;
8251 284 tempitem.wpn9 = 0;
8252 284 tempitem.wpn10 = 0;
8253 284 break;
8254 }
8255 case itype_divineprotection:
8256 {
8257 284 tempitem.flags &= ~ (item_flag5);
8258 284 tempitem.misc2 = 0;
8259 284 tempitem.misc3 = 0;
8260 284 tempitem.misc4 = 0;
8261 284 tempitem.misc5 = 0;
8262 284 tempitem.misc6 = 0;
8263 284 tempitem.misc7 = 0;
8264 284 tempitem.misc8 = 0;
8265 284 tempitem.misc9 = 0;
8266 284 tempitem.misc10 = 0;
8267 284 break;
8268 }
8269 case itype_bomb:
8270 {
8271 300 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8272 300 tempitem.misc4 = 0;
8273 300 tempitem.misc5 = 0;
8274 300 tempitem.misc6 = 0;
8275 300 tempitem.misc7 = 0;
8276 300 tempitem.misc8 = 0;
8277 300 tempitem.misc9 = 0;
8278 300 tempitem.misc10 = 0;
8279 300 tempitem.wpn3 = 0;
8280 300 tempitem.wpn4 = 0;
8281 300 tempitem.wpn5 = 0;
8282 300 tempitem.wpn6 = 0;
8283 300 tempitem.wpn7 = 0;
8284 300 tempitem.wpn8 = 0;
8285 300 tempitem.wpn9 = 0;
8286 300 tempitem.wpn10 = 0;
8287 300 break;
8288 }
8289 case itype_sbomb:
8290 {
8291 286 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8292 286 tempitem.misc4 = 0;
8293 286 tempitem.misc5 = 0;
8294 286 tempitem.misc6 = 0;
8295 286 tempitem.misc7 = 0;
8296 286 tempitem.misc8 = 0;
8297 286 tempitem.misc9 = 0;
8298 286 tempitem.misc10 = 0;
8299 286 tempitem.wpn3 = 0;
8300 286 tempitem.wpn4 = 0;
8301 286 tempitem.wpn5 = 0;
8302 286 tempitem.wpn6 = 0;
8303 286 tempitem.wpn7 = 0;
8304 286 tempitem.wpn8 = 0;
8305 286 tempitem.wpn9 = 0;
8306 286 tempitem.wpn10 = 0;
8307 286 break;
8308 }
8309 case itype_clock:
8310 {
8311 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8312 287 tempitem.misc2 = 0;
8313 287 tempitem.misc3 = 0;
8314 287 tempitem.misc4 = 0;
8315 287 tempitem.misc5 = 0;
8316 287 tempitem.misc6 = 0;
8317 287 tempitem.misc7 = 0;
8318 287 tempitem.misc8 = 0;
8319 287 tempitem.misc9 = 0;
8320 287 tempitem.misc10 = 0;
8321 287 tempitem.wpn = 0;
8322 287 tempitem.wpn2 = 0;
8323 287 tempitem.wpn3 = 0;
8324 287 tempitem.wpn4 = 0;
8325 287 tempitem.wpn5 = 0;
8326 287 tempitem.wpn6 = 0;
8327 287 tempitem.wpn7 = 0;
8328 287 tempitem.wpn8 = 0;
8329 287 tempitem.wpn9 = 0;
8330 287 tempitem.wpn10 = 0;
8331 287 break;
8332 }
8333 case itype_key:
8334 {
8335 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8336 284 tempitem.misc1 = 0;
8337 284 tempitem.misc2 = 0;
8338 284 tempitem.misc3 = 0;
8339 284 tempitem.misc4 = 0;
8340 284 tempitem.misc5 = 0;
8341 284 tempitem.misc6 = 0;
8342 284 tempitem.misc7 = 0;
8343 284 tempitem.misc8 = 0;
8344 284 tempitem.misc9 = 0;
8345 284 tempitem.misc10 = 0;
8346 284 tempitem.wpn = 0;
8347 284 tempitem.wpn2 = 0;
8348 284 tempitem.wpn3 = 0;
8349 284 tempitem.wpn4 = 0;
8350 284 tempitem.wpn5 = 0;
8351 284 tempitem.wpn6 = 0;
8352 284 tempitem.wpn7 = 0;
8353 284 tempitem.wpn8 = 0;
8354 284 tempitem.wpn9 = 0;
8355 284 tempitem.wpn10 = 0;
8356 284 break;
8357 }
8358 case itype_magiccontainer:
8359 {
8360 289 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8361 289 tempitem.misc1 = 0;
8362 289 tempitem.misc2 = 0;
8363 289 tempitem.misc3 = 0;
8364 289 tempitem.misc4 = 0;
8365 289 tempitem.misc5 = 0;
8366 289 tempitem.misc6 = 0;
8367 289 tempitem.misc7 = 0;
8368 289 tempitem.misc8 = 0;
8369 289 tempitem.misc9 = 0;
8370 289 tempitem.misc10 = 0;
8371 289 tempitem.wpn = 0;
8372 289 tempitem.wpn2 = 0;
8373 289 tempitem.wpn3 = 0;
8374 289 tempitem.wpn4 = 0;
8375 289 tempitem.wpn5 = 0;
8376 289 tempitem.wpn6 = 0;
8377 289 tempitem.wpn7 = 0;
8378 289 tempitem.wpn8 = 0;
8379 289 tempitem.wpn9 = 0;
8380 289 tempitem.wpn10 = 0;
8381 289 break;
8382 }
8383 case itype_triforcepiece:
8384 {
8385 568 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8386 568 tempitem.misc3 = 0;
8387 568 tempitem.misc4 = 0;
8388 568 tempitem.misc5 = 0;
8389 568 tempitem.misc6 = 0;
8390 568 tempitem.misc7 = 0;
8391 568 tempitem.misc8 = 0;
8392 568 tempitem.misc9 = 0;
8393 568 tempitem.misc10 = 0;
8394 568 tempitem.wpn = 0;
8395 568 tempitem.wpn2 = 0;
8396 568 tempitem.wpn3 = 0;
8397 568 tempitem.wpn4 = 0;
8398 568 tempitem.wpn5 = 0;
8399 568 tempitem.wpn6 = 0;
8400 568 tempitem.wpn7 = 0;
8401 568 tempitem.wpn8 = 0;
8402 568 tempitem.wpn9 = 0;
8403 568 tempitem.wpn10 = 0;
8404 568 break;
8405 }
8406 case itype_map: case itype_compass: case itype_bosskey:
8407 {
8408 857 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8409 857 tempitem.misc1 = 0;
8410 857 tempitem.misc2 = 0;
8411 857 tempitem.misc3 = 0;
8412 857 tempitem.misc4 = 0;
8413 857 tempitem.misc5 = 0;
8414 857 tempitem.misc6 = 0;
8415 857 tempitem.misc7 = 0;
8416 857 tempitem.misc8 = 0;
8417 857 tempitem.misc9 = 0;
8418 857 tempitem.misc10 = 0;
8419 857 tempitem.wpn = 0;
8420 857 tempitem.wpn2 = 0;
8421 857 tempitem.wpn3 = 0;
8422 857 tempitem.wpn4 = 0;
8423 857 tempitem.wpn5 = 0;
8424 857 tempitem.wpn6 = 0;
8425 857 tempitem.wpn7 = 0;
8426 857 tempitem.wpn8 = 0;
8427 857 tempitem.wpn9 = 0;
8428 857 tempitem.wpn10 = 0;
8429 857 break;
8430 }
8431 case itype_quiver:
8432 {
8433 1136 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8434 1136 tempitem.misc3 = 0;
8435 1136 tempitem.misc4 = 0;
8436 1136 tempitem.misc5 = 0;
8437 1136 tempitem.misc6 = 0;
8438 1136 tempitem.misc7 = 0;
8439 1136 tempitem.misc8 = 0;
8440 1136 tempitem.misc9 = 0;
8441 1136 tempitem.misc10 = 0;
8442 1136 tempitem.wpn = 0;
8443 1136 tempitem.wpn2 = 0;
8444 1136 tempitem.wpn3 = 0;
8445 1136 tempitem.wpn4 = 0;
8446 1136 tempitem.wpn5 = 0;
8447 1136 tempitem.wpn6 = 0;
8448 1136 tempitem.wpn7 = 0;
8449 1136 tempitem.wpn8 = 0;
8450 1136 tempitem.wpn9 = 0;
8451 1136 tempitem.wpn10 = 0;
8452 1136 break;
8453 }
8454 case itype_lkey:
8455 {
8456 785 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8457 785 tempitem.misc1 = 0;
8458 785 tempitem.misc2 = 0;
8459 785 tempitem.misc3 = 0;
8460 785 tempitem.misc4 = 0;
8461 785 tempitem.misc5 = 0;
8462 785 tempitem.misc6 = 0;
8463 785 tempitem.misc7 = 0;
8464 785 tempitem.misc8 = 0;
8465 785 tempitem.misc9 = 0;
8466 785 tempitem.misc10 = 0;
8467 785 tempitem.wpn = 0;
8468 785 tempitem.wpn2 = 0;
8469 785 tempitem.wpn3 = 0;
8470 785 tempitem.wpn4 = 0;
8471 785 tempitem.wpn5 = 0;
8472 785 tempitem.wpn6 = 0;
8473 785 tempitem.wpn7 = 0;
8474 785 tempitem.wpn8 = 0;
8475 785 tempitem.wpn9 = 0;
8476 785 tempitem.wpn10 = 0;
8477 785 break;
8478 }
8479 case itype_cbyrna:
8480 {
8481 284 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8482 284 tempitem.misc4 = 0;
8483 284 tempitem.misc5 = 0;
8484 284 tempitem.misc6 = 0;
8485 284 tempitem.misc7 = 0;
8486 284 tempitem.misc8 = 0;
8487 284 tempitem.misc9 = 0;
8488 284 tempitem.misc10 = 0;
8489 284 tempitem.wpn6 = 0;
8490 284 tempitem.wpn7 = 0;
8491 284 tempitem.wpn8 = 0;
8492 284 tempitem.wpn9 = 0;
8493 284 tempitem.wpn10 = 0;
8494 284 break;
8495 }
8496 case itype_rupee: case itype_arrowammo:
8497 {
8498 3317 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8499 3317 tempitem.misc1 = 0;
8500 3317 tempitem.misc2 = 0;
8501 3317 tempitem.misc3 = 0;
8502 3317 tempitem.misc4 = 0;
8503 3317 tempitem.misc5 = 0;
8504 3317 tempitem.misc6 = 0;
8505 3317 tempitem.misc7 = 0;
8506 3317 tempitem.misc8 = 0;
8507 3317 tempitem.misc9 = 0;
8508 3317 tempitem.misc10 = 0;
8509 3317 tempitem.wpn = 0;
8510 3317 tempitem.wpn2 = 0;
8511 3317 tempitem.wpn3 = 0;
8512 3317 tempitem.wpn4 = 0;
8513 3317 tempitem.wpn5 = 0;
8514 3317 tempitem.wpn6 = 0;
8515 3317 tempitem.wpn7 = 0;
8516 3317 tempitem.wpn8 = 0;
8517 3317 tempitem.wpn9 = 0;
8518 3317 tempitem.wpn10 = 0;
8519 3317 break;
8520 }
8521 case itype_fairy:
8522 {
8523 555 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8524 555 tempitem.misc4 = 0;
8525 555 tempitem.misc5 = 0;
8526 555 tempitem.misc6 = 0;
8527 555 tempitem.misc7 = 0;
8528 555 tempitem.misc8 = 0;
8529 555 tempitem.misc9 = 0;
8530 555 tempitem.misc10 = 0;
8531 555 tempitem.wpn = 0;
8532 555 tempitem.wpn2 = 0;
8533 555 tempitem.wpn3 = 0;
8534 555 tempitem.wpn4 = 0;
8535 555 tempitem.wpn5 = 0;
8536 555 tempitem.wpn6 = 0;
8537 555 tempitem.wpn7 = 0;
8538 555 tempitem.wpn8 = 0;
8539 555 tempitem.wpn9 = 0;
8540 555 tempitem.wpn10 = 0;
8541 555 break;
8542 }
8543 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8544 {
8545 2923 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8546 2923 tempitem.misc1 = 0;
8547 2923 tempitem.misc2 = 0;
8548 2923 tempitem.misc3 = 0;
8549 2923 tempitem.misc4 = 0;
8550 2923 tempitem.misc5 = 0;
8551 2923 tempitem.misc6 = 0;
8552 2923 tempitem.misc7 = 0;
8553 2923 tempitem.misc8 = 0;
8554 2923 tempitem.misc9 = 0;
8555 2923 tempitem.misc10 = 0;
8556 2923 tempitem.wpn = 0;
8557 2923 tempitem.wpn2 = 0;
8558 2923 tempitem.wpn3 = 0;
8559 2923 tempitem.wpn4 = 0;
8560 2923 tempitem.wpn5 = 0;
8561 2923 tempitem.wpn6 = 0;
8562 2923 tempitem.wpn7 = 0;
8563 2923 tempitem.wpn8 = 0;
8564 2923 tempitem.wpn9 = 0;
8565 2923 tempitem.wpn10 = 0;
8566 2923 break;
8567 }
8568 case itype_bombbag:
8569 {
8570 1136 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8571 1136 tempitem.misc3 = 0;
8572 1136 tempitem.misc4 = 0;
8573 1136 tempitem.misc5 = 0;
8574 1136 tempitem.misc6 = 0;
8575 1136 tempitem.misc7 = 0;
8576 1136 tempitem.misc8 = 0;
8577 1136 tempitem.misc9 = 0;
8578 1136 tempitem.misc10 = 0;
8579 1136 tempitem.wpn = 0;
8580 1136 tempitem.wpn2 = 0;
8581 1136 tempitem.wpn3 = 0;
8582 1136 tempitem.wpn4 = 0;
8583 1136 tempitem.wpn5 = 0;
8584 1136 tempitem.wpn6 = 0;
8585 1136 tempitem.wpn7 = 0;
8586 1136 tempitem.wpn8 = 0;
8587 1136 tempitem.wpn9 = 0;
8588 1136 tempitem.wpn10 = 0;
8589 1136 break;
8590 }
8591 case itype_rocs:
8592 {
8593 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8594 284 tempitem.misc1 = 0;
8595 284 tempitem.misc2 = 0;
8596 284 tempitem.misc3 = 0;
8597 284 tempitem.misc4 = 0;
8598 284 tempitem.misc5 = 0;
8599 284 tempitem.misc6 = 0;
8600 284 tempitem.misc7 = 0;
8601 284 tempitem.misc8 = 0;
8602 284 tempitem.misc9 = 0;
8603 284 tempitem.misc10 = 0;
8604 284 tempitem.wpn = 0;
8605 284 tempitem.wpn2 = 0;
8606 284 tempitem.wpn3 = 0;
8607 284 tempitem.wpn4 = 0;
8608 284 tempitem.wpn5 = 0;
8609 284 tempitem.wpn6 = 0;
8610 284 tempitem.wpn7 = 0;
8611 284 tempitem.wpn8 = 0;
8612 284 tempitem.wpn9 = 0;
8613 284 tempitem.wpn10 = 0;
8614 284 break;
8615 }
8616 case itype_hoverboots:
8617 {
8618 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8619 284 tempitem.misc2 = 0;
8620 284 tempitem.misc3 = 0;
8621 284 tempitem.misc4 = 0;
8622 284 tempitem.misc5 = 0;
8623 284 tempitem.misc6 = 0;
8624 284 tempitem.misc7 = 0;
8625 284 tempitem.misc8 = 0;
8626 284 tempitem.misc9 = 0;
8627 284 tempitem.misc10 = 0;
8628 284 tempitem.wpn2 = 0;
8629 284 tempitem.wpn3 = 0;
8630 284 tempitem.wpn4 = 0;
8631 284 tempitem.wpn5 = 0;
8632 284 tempitem.wpn6 = 0;
8633 284 tempitem.wpn7 = 0;
8634 284 tempitem.wpn8 = 0;
8635 284 tempitem.wpn9 = 0;
8636 284 tempitem.wpn10 = 0;
8637 284 break;
8638 }
8639 case itype_spinscroll:
8640 {
8641 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8642 284 tempitem.misc2 = 0;
8643 284 tempitem.misc3 = 0;
8644 284 tempitem.misc4 = 0;
8645 284 tempitem.misc5 = 0;
8646 284 tempitem.misc6 = 0;
8647 284 tempitem.misc7 = 0;
8648 284 tempitem.misc8 = 0;
8649 284 tempitem.misc9 = 0;
8650 284 tempitem.misc10 = 0;
8651 284 tempitem.wpn = 0;
8652 284 tempitem.wpn2 = 0;
8653 284 tempitem.wpn3 = 0;
8654 284 tempitem.wpn4 = 0;
8655 284 tempitem.wpn5 = 0;
8656 284 tempitem.wpn6 = 0;
8657 284 tempitem.wpn7 = 0;
8658 284 tempitem.wpn8 = 0;
8659 284 tempitem.wpn9 = 0;
8660 284 tempitem.wpn10 = 0;
8661 284 break;
8662 }
8663 case itype_crossscroll:
8664 {
8665 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8666 284 tempitem.misc1 = 0;
8667 284 tempitem.misc2 = 0;
8668 284 tempitem.misc3 = 0;
8669 284 tempitem.misc4 = 0;
8670 284 tempitem.misc5 = 0;
8671 284 tempitem.misc6 = 0;
8672 284 tempitem.misc7 = 0;
8673 284 tempitem.misc8 = 0;
8674 284 tempitem.misc9 = 0;
8675 284 tempitem.misc10 = 0;
8676 284 tempitem.wpn = 0;
8677 284 tempitem.wpn2 = 0;
8678 284 tempitem.wpn3 = 0;
8679 284 tempitem.wpn4 = 0;
8680 284 tempitem.wpn5 = 0;
8681 284 tempitem.wpn6 = 0;
8682 284 tempitem.wpn7 = 0;
8683 284 tempitem.wpn8 = 0;
8684 284 tempitem.wpn9 = 0;
8685 284 tempitem.wpn10 = 0;
8686 284 break;
8687 }
8688 case itype_quakescroll:
8689 {
8690 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8691 284 tempitem.misc3 = 0;
8692 284 tempitem.misc4 = 0;
8693 284 tempitem.misc5 = 0;
8694 284 tempitem.misc6 = 0;
8695 284 tempitem.misc7 = 0;
8696 284 tempitem.misc8 = 0;
8697 284 tempitem.misc9 = 0;
8698 284 tempitem.misc10 = 0;
8699 284 tempitem.wpn = 0;
8700 284 tempitem.wpn2 = 0;
8701 284 tempitem.wpn3 = 0;
8702 284 tempitem.wpn4 = 0;
8703 284 tempitem.wpn5 = 0;
8704 284 tempitem.wpn6 = 0;
8705 284 tempitem.wpn7 = 0;
8706 284 tempitem.wpn8 = 0;
8707 284 tempitem.wpn9 = 0;
8708 284 tempitem.wpn10 = 0;
8709 284 break;
8710 }
8711 case itype_whispring:
8712 {
8713 571 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8714 571 tempitem.misc2 = 0;
8715 571 tempitem.misc3 = 0;
8716 571 tempitem.misc4 = 0;
8717 571 tempitem.misc5 = 0;
8718 571 tempitem.misc6 = 0;
8719 571 tempitem.misc7 = 0;
8720 571 tempitem.misc8 = 0;
8721 571 tempitem.misc9 = 0;
8722 571 tempitem.misc10 = 0;
8723 571 tempitem.wpn = 0;
8724 571 tempitem.wpn2 = 0;
8725 571 tempitem.wpn3 = 0;
8726 571 tempitem.wpn4 = 0;
8727 571 tempitem.wpn5 = 0;
8728 571 tempitem.wpn6 = 0;
8729 571 tempitem.wpn7 = 0;
8730 571 tempitem.wpn8 = 0;
8731 571 tempitem.wpn9 = 0;
8732 571 tempitem.wpn10 = 0;
8733 571 break;
8734 }
8735 case itype_chargering:
8736 {
8737 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8738 568 tempitem.misc3 = 0;
8739 568 tempitem.misc4 = 0;
8740 568 tempitem.misc5 = 0;
8741 568 tempitem.misc6 = 0;
8742 568 tempitem.misc7 = 0;
8743 568 tempitem.misc8 = 0;
8744 568 tempitem.misc9 = 0;
8745 568 tempitem.misc10 = 0;
8746 568 tempitem.wpn = 0;
8747 568 tempitem.wpn2 = 0;
8748 568 tempitem.wpn3 = 0;
8749 568 tempitem.wpn4 = 0;
8750 568 tempitem.wpn5 = 0;
8751 568 tempitem.wpn6 = 0;
8752 568 tempitem.wpn7 = 0;
8753 568 tempitem.wpn8 = 0;
8754 568 tempitem.wpn9 = 0;
8755 568 tempitem.wpn10 = 0;
8756 568 break;
8757 }
8758 case itype_perilscroll:
8759 {
8760 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8761 284 tempitem.misc2 = 0;
8762 284 tempitem.misc3 = 0;
8763 284 tempitem.misc4 = 0;
8764 284 tempitem.misc5 = 0;
8765 284 tempitem.misc6 = 0;
8766 284 tempitem.misc7 = 0;
8767 284 tempitem.misc8 = 0;
8768 284 tempitem.misc9 = 0;
8769 284 tempitem.misc10 = 0;
8770 284 tempitem.wpn = 0;
8771 284 tempitem.wpn2 = 0;
8772 284 tempitem.wpn3 = 0;
8773 284 tempitem.wpn4 = 0;
8774 284 tempitem.wpn5 = 0;
8775 284 tempitem.wpn6 = 0;
8776 284 tempitem.wpn7 = 0;
8777 284 tempitem.wpn8 = 0;
8778 284 tempitem.wpn9 = 0;
8779 284 tempitem.wpn10 = 0;
8780 284 break;
8781 }
8782 case itype_wealthmedal:
8783 {
8784 855 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8785 855 tempitem.misc2 = 0;
8786 855 tempitem.misc3 = 0;
8787 855 tempitem.misc4 = 0;
8788 855 tempitem.misc5 = 0;
8789 855 tempitem.misc6 = 0;
8790 855 tempitem.misc7 = 0;
8791 855 tempitem.misc8 = 0;
8792 855 tempitem.misc9 = 0;
8793 855 tempitem.misc10 = 0;
8794 855 tempitem.wpn = 0;
8795 855 tempitem.wpn2 = 0;
8796 855 tempitem.wpn3 = 0;
8797 855 tempitem.wpn4 = 0;
8798 855 tempitem.wpn5 = 0;
8799 855 tempitem.wpn6 = 0;
8800 855 tempitem.wpn7 = 0;
8801 855 tempitem.wpn8 = 0;
8802 855 tempitem.wpn9 = 0;
8803 855 tempitem.wpn10 = 0;
8804 855 break;
8805 }
8806 case itype_heartring:
8807 {
8808 858 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8809 858 tempitem.misc3 = 0;
8810 858 tempitem.misc4 = 0;
8811 858 tempitem.misc5 = 0;
8812 858 tempitem.misc6 = 0;
8813 858 tempitem.misc7 = 0;
8814 858 tempitem.misc8 = 0;
8815 858 tempitem.misc9 = 0;
8816 858 tempitem.misc10 = 0;
8817 858 tempitem.wpn = 0;
8818 858 tempitem.wpn2 = 0;
8819 858 tempitem.wpn3 = 0;
8820 858 tempitem.wpn4 = 0;
8821 858 tempitem.wpn5 = 0;
8822 858 tempitem.wpn6 = 0;
8823 858 tempitem.wpn7 = 0;
8824 858 tempitem.wpn8 = 0;
8825 858 tempitem.wpn9 = 0;
8826 858 tempitem.wpn10 = 0;
8827 858 break;
8828 }
8829 case itype_magicring:
8830 {
8831 1148 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8832 1148 tempitem.misc3 = 0;
8833 1148 tempitem.misc4 = 0;
8834 1148 tempitem.misc5 = 0;
8835 1148 tempitem.misc6 = 0;
8836 1148 tempitem.misc7 = 0;
8837 1148 tempitem.misc8 = 0;
8838 1148 tempitem.misc9 = 0;
8839 1148 tempitem.misc10 = 0;
8840 1148 tempitem.wpn = 0;
8841 1148 tempitem.wpn2 = 0;
8842 1148 tempitem.wpn3 = 0;
8843 1148 tempitem.wpn4 = 0;
8844 1148 tempitem.wpn5 = 0;
8845 1148 tempitem.wpn6 = 0;
8846 1148 tempitem.wpn7 = 0;
8847 1148 tempitem.wpn8 = 0;
8848 1148 tempitem.wpn9 = 0;
8849 1148 tempitem.wpn10 = 0;
8850 1148 break;
8851 }
8852 case itype_spinscroll2:
8853 {
8854 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8855 284 tempitem.misc2 = 0;
8856 284 tempitem.misc3 = 0;
8857 284 tempitem.misc4 = 0;
8858 284 tempitem.misc5 = 0;
8859 284 tempitem.misc6 = 0;
8860 284 tempitem.misc7 = 0;
8861 284 tempitem.misc8 = 0;
8862 284 tempitem.misc9 = 0;
8863 284 tempitem.misc10 = 0;
8864 284 tempitem.wpn = 0;
8865 284 tempitem.wpn2 = 0;
8866 284 tempitem.wpn3 = 0;
8867 284 tempitem.wpn4 = 0;
8868 284 tempitem.wpn5 = 0;
8869 284 tempitem.wpn6 = 0;
8870 284 tempitem.wpn7 = 0;
8871 284 tempitem.wpn8 = 0;
8872 284 tempitem.wpn9 = 0;
8873 284 tempitem.wpn10 = 0;
8874 284 break;
8875 }
8876 case itype_quakescroll2:
8877 {
8878 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8879 284 tempitem.misc3 = 0;
8880 284 tempitem.misc4 = 0;
8881 284 tempitem.misc5 = 0;
8882 284 tempitem.misc6 = 0;
8883 284 tempitem.misc7 = 0;
8884 284 tempitem.misc8 = 0;
8885 284 tempitem.misc9 = 0;
8886 284 tempitem.misc10 = 0;
8887 284 tempitem.wpn = 0;
8888 284 tempitem.wpn2 = 0;
8889 284 tempitem.wpn3 = 0;
8890 284 tempitem.wpn4 = 0;
8891 284 tempitem.wpn5 = 0;
8892 284 tempitem.wpn6 = 0;
8893 284 tempitem.wpn7 = 0;
8894 284 tempitem.wpn8 = 0;
8895 284 tempitem.wpn9 = 0;
8896 284 tempitem.wpn10 = 0;
8897 284 break;
8898 }
8899 case itype_agony:
8900 {
8901 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8902 284 tempitem.misc2 = 0;
8903 284 tempitem.misc3 = 0;
8904 284 tempitem.misc4 = 0;
8905 284 tempitem.misc5 = 0;
8906 284 tempitem.misc6 = 0;
8907 284 tempitem.misc7 = 0;
8908 284 tempitem.misc8 = 0;
8909 284 tempitem.misc9 = 0;
8910 284 tempitem.misc10 = 0;
8911 284 tempitem.wpn = 0;
8912 284 tempitem.wpn2 = 0;
8913 284 tempitem.wpn3 = 0;
8914 284 tempitem.wpn4 = 0;
8915 284 tempitem.wpn5 = 0;
8916 284 tempitem.wpn6 = 0;
8917 284 tempitem.wpn7 = 0;
8918 284 tempitem.wpn8 = 0;
8919 284 tempitem.wpn9 = 0;
8920 284 tempitem.wpn10 = 0;
8921 284 break;
8922 }
8923 case itype_stompboots:
8924 {
8925 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8926 284 tempitem.misc1 = 0;
8927 284 tempitem.misc2 = 0;
8928 284 tempitem.misc3 = 0;
8929 284 tempitem.misc4 = 0;
8930 284 tempitem.misc5 = 0;
8931 284 tempitem.misc6 = 0;
8932 284 tempitem.misc7 = 0;
8933 284 tempitem.misc8 = 0;
8934 284 tempitem.misc9 = 0;
8935 284 tempitem.misc10 = 0;
8936 284 tempitem.wpn = 0;
8937 284 tempitem.wpn2 = 0;
8938 284 tempitem.wpn3 = 0;
8939 284 tempitem.wpn4 = 0;
8940 284 tempitem.wpn5 = 0;
8941 284 tempitem.wpn6 = 0;
8942 284 tempitem.wpn7 = 0;
8943 284 tempitem.wpn8 = 0;
8944 284 tempitem.wpn9 = 0;
8945 284 tempitem.wpn10 = 0;
8946 284 break;
8947 }
8948 case itype_whimsicalring:
8949 {
8950 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8951 284 tempitem.misc2 = 0;
8952 284 tempitem.misc3 = 0;
8953 284 tempitem.misc4 = 0;
8954 284 tempitem.misc5 = 0;
8955 284 tempitem.misc6 = 0;
8956 284 tempitem.misc7 = 0;
8957 284 tempitem.misc8 = 0;
8958 284 tempitem.misc9 = 0;
8959 284 tempitem.misc10 = 0;
8960 284 tempitem.wpn = 0;
8961 284 tempitem.wpn2 = 0;
8962 284 tempitem.wpn3 = 0;
8963 284 tempitem.wpn4 = 0;
8964 284 tempitem.wpn5 = 0;
8965 284 tempitem.wpn6 = 0;
8966 284 tempitem.wpn7 = 0;
8967 284 tempitem.wpn8 = 0;
8968 284 tempitem.wpn9 = 0;
8969 284 tempitem.wpn10 = 0;
8970 284 break;
8971 }
8972 case itype_perilring:
8973 {
8974 311 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8975 311 tempitem.misc2 = 0;
8976 311 tempitem.misc3 = 0;
8977 311 tempitem.misc4 = 0;
8978 311 tempitem.misc5 = 0;
8979 311 tempitem.misc6 = 0;
8980 311 tempitem.misc7 = 0;
8981 311 tempitem.misc8 = 0;
8982 311 tempitem.misc9 = 0;
8983 311 tempitem.misc10 = 0;
8984 311 tempitem.wpn = 0;
8985 311 tempitem.wpn2 = 0;
8986 311 tempitem.wpn3 = 0;
8987 311 tempitem.wpn4 = 0;
8988 311 tempitem.wpn5 = 0;
8989 311 tempitem.wpn6 = 0;
8990 311 tempitem.wpn7 = 0;
8991 311 tempitem.wpn8 = 0;
8992 311 tempitem.wpn9 = 0;
8993 311 tempitem.wpn10 = 0;
8994 311 break;
8995 }
8996 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
8997 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
8998 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
8999 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9000 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9001 {
9002 10996 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9003 10996 tempitem.misc1 = 0;
9004 10996 tempitem.misc2 = 0;
9005 10996 tempitem.misc3 = 0;
9006 10996 tempitem.misc4 = 0;
9007 10996 tempitem.misc5 = 0;
9008 10996 tempitem.misc6 = 0;
9009 10996 tempitem.misc7 = 0;
9010 10996 tempitem.misc8 = 0;
9011 10996 tempitem.misc9 = 0;
9012 10996 tempitem.misc10 = 0;
9013 10996 tempitem.wpn = 0;
9014 10996 tempitem.wpn2 = 0;
9015 10996 tempitem.wpn3 = 0;
9016 10996 tempitem.wpn4 = 0;
9017 10996 tempitem.wpn5 = 0;
9018 10996 tempitem.wpn6 = 0;
9019 10996 tempitem.wpn7 = 0;
9020 10996 tempitem.wpn8 = 0;
9021 10996 tempitem.wpn9 = 0;
9022 10996 tempitem.wpn10 = 0;
9023 10996 break;
9024 }
9025 }
9026 73472 }
9027 //Port quest rules to items
9028
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version <= 31)
9029 {
9030
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 73172 times.
73472 if(tempitem.family == itype_bomb)
9031 {
9032
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 144 times.
300 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9033 144 else tempitem.flags &= ~ item_flag2;
9034 300 }
9035
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 72886 times.
73172 else if(tempitem.family == itype_sbomb)
9036 {
9037
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 128 times.
286 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9038 128 else tempitem.flags &= ~ item_flag2;
9039 286 }
9040
9041
2/2
✓ Branch 0 taken 859 times.
✓ Branch 1 taken 72027 times.
72886 else if(tempitem.family == itype_brang)
9042 {
9043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 859 times.
859 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9044 859 else tempitem.flags &= ~ item_flag4;
9045 859 }
9046
2/2
✓ Branch 0 taken 71725 times.
✓ Branch 1 taken 302 times.
72027 else if(tempitem.family == itype_wand)
9047 {
9048
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 278 times.
302 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9049 278 else tempitem.flags &= ~ item_flag3;
9050 302 }
9051 73472 }
9052
9053 //Port quest rules to items
9054
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version <= 37)
9055 {
9056
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 73185 times.
73472 if(tempitem.family == itype_flippers)
9057 {
9058
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 208 times.
287 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9059 208 else tempitem.flags &= ~ item_flag1;
9060 287 }
9061
2/2
✓ Branch 0 taken 55497 times.
✓ Branch 1 taken 17688 times.
73185 else if(tempitem.family == itype_sword)
9062 {
9063
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 17226 times.
17688 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9064 17226 else tempitem.flags &= ~ item_flag5;
9065 17688 }
9066
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 55195 times.
55497 else if(tempitem.family == itype_wand)
9067 {
9068
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 292 times.
302 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9069 292 else tempitem.flags &= ~ item_flag5;
9070 302 }
9071
4/4
✓ Branch 0 taken 54895 times.
✓ Branch 1 taken 300 times.
✓ Branch 2 taken 610 times.
✓ Branch 3 taken 54285 times.
55195 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9072 {
9073 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9074
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 529 times.
910 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9075 529 else tempitem.flags &= ~ item_flag3;
9076 910 }
9077 73472 }
9078
9079
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 38)
9080 {
9081
4/4
✓ Branch 0 taken 72613 times.
✓ Branch 1 taken 859 times.
✓ Branch 2 taken 570 times.
✓ Branch 3 taken 72043 times.
73472 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9082 {
9083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1429 times.
1429 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9084 1429 else tempitem.flags &= ~item_flag4;
9085
9086
2/2
✓ Branch 0 taken 703 times.
✓ Branch 1 taken 726 times.
1429 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9087 726 else tempitem.flags &= ~(item_flag5|item_flag6);
9088 1429 }
9089
2/2
✓ Branch 0 taken 71199 times.
✓ Branch 1 taken 844 times.
72043 else if(tempitem.family == itype_arrow)
9090 {
9091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9092 844 else tempitem.flags &= ~item_flag4;
9093
9094
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 432 times.
844 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9095 432 else tempitem.flags |= item_flag2;
9096 844 }
9097 73472 }
9098
9099
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 39)
9100 {
9101
6/6
✓ Branch 0 taken 73188 times.
✓ Branch 1 taken 284 times.
✓ Branch 2 taken 72888 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 610 times.
✓ Branch 5 taken 72278 times.
73472 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9102 {
9103
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1178 times.
1194 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9104 1178 else tempitem.flags &= ~item_flag5;
9105 1194 }
9106
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 71655 times.
72278 else if(tempitem.family == itype_potion)
9107 {
9108
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 461 times.
623 if(get_qr(qr_NONBUBBLEMEDICINE))
9109 {
9110 162 tempitem.flags &= ~(item_flag3|item_flag4);
9111 162 }
9112 else
9113 {
9114 461 tempitem.flags |= item_flag3;
9115
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 331 times.
461 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9116 331 else tempitem.flags &= ~item_flag4;
9117 }
9118 623 }
9119
2/2
✓ Branch 0 taken 71087 times.
✓ Branch 1 taken 568 times.
71655 else if(tempitem.family == itype_triforcepiece)
9120 {
9121
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 484 times.
568 if(get_qr(qr_NONBUBBLETRIFORCE))
9122 {
9123 84 tempitem.flags |= item_flag3;
9124
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9125 28 else tempitem.flags &= ~item_flag4;
9126 84 }
9127 else
9128 {
9129 484 tempitem.flags &= ~(item_flag3|item_flag4);
9130 }
9131 568 }
9132 73472 }
9133
9134
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 40)
9135 {
9136
4/4
✓ Branch 0 taken 72540 times.
✓ Branch 1 taken 932 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 72229 times.
73472 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9137 {
9138
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 930 times.
1243 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9139 930 else tempitem.flags &= ~item_flag1;
9140 1243 }
9141
8/8
✓ Branch 0 taken 71619 times.
✓ Branch 1 taken 610 times.
✓ Branch 2 taken 53931 times.
✓ Branch 3 taken 17688 times.
✓ Branch 4 taken 53629 times.
✓ Branch 5 taken 302 times.
✓ Branch 6 taken 284 times.
✓ Branch 7 taken 53345 times.
72229 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9142 {
9143
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18776 times.
18884 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9144 18776 else tempitem.flags &= ~item_flag8;
9145 18884 }
9146
6/6
✓ Branch 0 taken 55784 times.
✓ Branch 1 taken 17688 times.
✓ Branch 2 taken 55482 times.
✓ Branch 3 taken 302 times.
✓ Branch 4 taken 287 times.
✓ Branch 5 taken 55195 times.
73472 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9147 {
9148
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 18173 times.
18277 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9149 18173 else tempitem.flags &= ~item_flag7;
9150 18277 }
9151
2/2
✓ Branch 0 taken 54911 times.
✓ Branch 1 taken 284 times.
55195 else if(tempitem.family == itype_cbyrna)
9152 {
9153 284 tempitem.flags |= item_flag7;
9154 284 }
9155 73472 }
9156
9157
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 41 )
9158 {
9159
2/2
✓ Branch 0 taken 55784 times.
✓ Branch 1 taken 17688 times.
73472 if(tempitem.family == itype_sword)
9160 {
9161
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 17404 times.
17688 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9162 17404 else tempitem.flags &= ~item_flag9;
9163
9164
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17260 times.
17688 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9165 17260 else tempitem.flags &= ~item_flag10;
9166 17688 }
9167 73472 }
9168
9169
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 42 )
9170 {
9171
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 73170 times.
73472 if(tempitem.family == itype_wand)
9172 {
9173
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 278 times.
302 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9174 278 else tempitem.flags &= ~item_flag3;
9175
9176 302 tempitem.flags &= ~item_flag6;
9177 302 }
9178
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 72883 times.
73170 else if(tempitem.family == itype_hammer)
9179 {
9180 287 tempitem.flags &= ~item_flag3;
9181 287 }
9182
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 72599 times.
72883 else if(tempitem.family == itype_cbyrna)
9183 {
9184 284 tempitem.flags |= item_flag3;
9185
9186 284 tempitem.flags &= ~item_flag6;
9187 284 }
9188
2/2
✓ Branch 0 taken 54911 times.
✓ Branch 1 taken 17688 times.
72599 else if(tempitem.family == itype_sword)
9189 {
9190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17688 times.
17688 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9191 17688 else tempitem.flags &= ~item_flag6;
9192 17688 }
9193 73472 }
9194
9195
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 43 )
9196 {
9197
2/2
✓ Branch 0 taken 73140 times.
✓ Branch 1 taken 332 times.
73472 if(tempitem.family == itype_whistle)
9198 {
9199
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 320 times.
332 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9200 320 else tempitem.flags &= ~item_flag3;
9201 332 }
9202 73472 }
9203
9204
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 45 )
9205 {
9206
2/2
✓ Branch 0 taken 73185 times.
✓ Branch 1 taken 287 times.
73472 if(tempitem.family == itype_flippers)
9207 {
9208 287 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9209 287 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9210 287 }
9211 73472 }
9212
9213
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 46 )
9214 {
9215
2/2
✓ Branch 0 taken 73188 times.
✓ Branch 1 taken 284 times.
73472 if(tempitem.family == itype_raft)
9216 {
9217 284 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9218 284 }
9219 73472 }
9220
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if ( s_version < 34 ) //! set the default counter for older quests.
9221 {
9222
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 73357 times.
73472 if ( (tempitem.flags & item_rupee_magic) )
9223 {
9224 115 tempitem.cost_counter[0] = 1;
9225 115 }
9226 else
9227 {
9228
2/2
✓ Branch 0 taken 44032 times.
✓ Branch 1 taken 29325 times.
73357 if(get_qr(qr_ENABLEMAGIC))
9229 44032 tempitem.cost_counter[0] = 4;
9230 else
9231 {
9232 29325 tempitem.cost_amount[0] = 0;
9233 29325 tempitem.cost_counter[0] = -1;
9234 }
9235 }
9236 73472 }
9237
9238
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if ( s_version < 35 ) //new Lens of Truth flags
9239 {
9240
2/2
✓ Branch 0 taken 73212 times.
✓ Branch 1 taken 260 times.
73472 if ( tempitem.family == itype_lens )
9241 {
9242
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 12 times.
260 if ( get_qr(qr_RAFTLENS) )
9243 {
9244 12 tempitem.flags |= item_flag4;
9245 12 }
9246
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 167 times.
260 if ( get_qr(qr_LENSHINTS) )
9247 {
9248 167 tempitem.flags |= item_flag1;
9249 167 }
9250
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 16 times.
260 if ( get_qr(qr_LENSSEESENEMIES) )
9251 {
9252 16 tempitem.flags |= item_flag5;
9253 16 }
9254 260 }
9255 73472 }
9256
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9257 {
9258
2/2
✓ Branch 0 taken 587776 times.
✓ Branch 1 taken 73472 times.
661248 for ( int32_t q = 0; q < 8; q++ )
9259 {
9260 587776 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9261 587776 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9262 587776 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9263 587776 tempitem.sprite_initiald[q] = 0;
9264 587776 }
9265 73472 tempitem.sprite_script = 0;
9266 73472 }
9267
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9268 {
9269 73472 tempitem.pickupflag = 0;
9270 73472 }
9271
9272
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 51 )
9273 {
9274
2/2
✓ Branch 0 taken 72862 times.
✓ Branch 1 taken 610 times.
73472 if( tempitem.family == itype_candle )
9275 {
9276 610 tempitem.misc4 = 50; //Step speed
9277 610 }
9278 73472 }
9279
9280
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 52 )
9281 {
9282
2/2
✓ Branch 0 taken 72599 times.
✓ Branch 1 taken 873 times.
73472 if( tempitem.family == itype_shield )
9283 873 tempitem.flags |= item_flag1; //'Block Front' flag
9284 73472 }
9285
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if(s_version < 53)
9286 {
9287
4/4
✓ Branch 0 taken 72042 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 286 times.
73472 switch(tempitem.family)
9288 {
9289 case itype_arrow:
9290 844 tempitem.cost_counter[1] = crARROWS;
9291 844 tempitem.cost_amount[1] = 1;
9292 844 break;
9293 case itype_bomb:
9294 300 tempitem.cost_counter[1] = crBOMBS;
9295 300 tempitem.cost_amount[1] = 1;
9296 300 break;
9297 case itype_sbomb:
9298 286 tempitem.cost_counter[1] = crSBOMBS;
9299 286 tempitem.cost_amount[1] = 1;
9300 286 break;
9301 default:
9302 72042 tempitem.cost_counter[1] = crNONE;
9303 72042 tempitem.cost_amount[1] = 0;
9304 72042 }
9305 73472 tempitem.magiccosttimer[1] = 0;
9306 73472 }
9307
2/2
✓ Branch 0 taken 43776 times.
✓ Branch 1 taken 76288 times.
120064 if( s_version < 54 )
9308 {
9309
2/2
✓ Branch 0 taken 75988 times.
✓ Branch 1 taken 300 times.
76288 if( tempitem.family == itype_flippers )
9310 300 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9311 76288 }
9312
2/2
✓ Branch 0 taken 43776 times.
✓ Branch 1 taken 76288 times.
120064 if(s_version < 55)
9313 {
9314
3/3
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 590 times.
✓ Branch 2 taken 75108 times.
76288 switch(tempitem.family)
9315 {
9316 case itype_spinscroll:
9317 case itype_quakescroll:
9318 590 tempitem.usesound2 = WAV_ZN1CHARGE;
9319 590 break;
9320 case itype_spinscroll2:
9321 case itype_quakescroll2:
9322 590 tempitem.usesound2 = WAV_ZN1CHARGE2;
9323 590 break;
9324 }
9325 76288 }
9326
2/2
✓ Branch 0 taken 43776 times.
✓ Branch 1 taken 76288 times.
120064 if(s_version < 56)
9327 {
9328
4/4
✓ Branch 0 taken 75046 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 311 times.
76288 switch(tempitem.family)
9329 {
9330 case itype_divinefire:
9331
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 11 times.
295 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9332
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 213 times.
295 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9333 295 tempitem.flags |= item_flag11; //Divine Fire
9334 295 break;
9335 case itype_candle:
9336
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 319 times.
636 SETFLAG(tempitem.flags, item_flag9, tempitem.fam_type > 1); //Strong Fire
9337 636 tempitem.flags &= ~item_flag10; //Magic Fire
9338 636 tempitem.flags &= ~item_flag11; //Divine Fire
9339 636 break;
9340 case itype_book:
9341 311 tempitem.flags |= item_flag9; //Strong Fire
9342 311 tempitem.flags |= item_flag10; //Magic Fire
9343 311 tempitem.flags &= ~item_flag11; //Divine Fire
9344 311 break;
9345 }
9346 76288 }
9347
2/2
✓ Branch 0 taken 30464 times.
✓ Branch 1 taken 89600 times.
120064 if (s_version < 61)
9348 {
9349
2/2
✓ Branch 0 taken 70649 times.
✓ Branch 1 taken 18951 times.
89600 switch (tempitem.family)
9350 {
9351 case itype_sword:
9352 18951 tempitem.usesound2 = WAV_BEAM;
9353 18951 break;
9354 }
9355 89600 }
9356
9357
9358
2/2
✓ Branch 0 taken 109076 times.
✓ Branch 1 taken 10988 times.
120064 if(tempitem.fam_type==0) // Always do this
9359 10988 tempitem.fam_type=1;
9360
9361 120064 itemsbuf[i] = tempitem;
9362 120064 }
9363
9364 469 return 0;
9365 470 }
9366
9367 static bool did_init_def_items = false;
9368 239994 void init_def_items()
9369 {
9370
2/2
✓ Branch 0 taken 239631 times.
✓ Branch 1 taken 363 times.
239994 if(did_init_def_items) return;
9371 363 did_init_def_items = true;
9372 363 default_items[3].cost_counter[1] = crBOMBS;
9373 363 default_items[13].cost_counter[1] = crARROWS;
9374 363 default_items[14].cost_counter[1] = crARROWS;
9375 363 default_items[48].cost_counter[1] = crSBOMBS;
9376 363 default_items[57].cost_counter[1] = crARROWS;
9377 239994 }
9378 239994 void reset_itembuf(itemdata *item, int32_t id)
9379 {
9380 239994 init_def_items();
9381
2/2
✓ Branch 0 taken 100683 times.
✓ Branch 1 taken 139311 times.
239994 if(id<iLast)
9382 {
9383 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9384 139311 word tile = item->tile;
9385 139311 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9386 139311 int32_t ltm = item->ltm;
9387
9388 139311 *item = default_items[id];
9389 139311 item->tile = tile;
9390 139311 item->misc_flags = miscs;
9391 139311 item->csets = cset;
9392 139311 item->frames = frames;
9393 139311 item->speed = speed;
9394 139311 item->delay = delay;
9395 139311 item->ltm = ltm;
9396 139311 }
9397 239994 }
9398
9399 100096 void reset_itemname(int32_t id)
9400 {
9401 100096 sprintf(item_string[id],"zz%03d",id);
9402
9403
2/2
✓ Branch 0 taken 44183 times.
✓ Branch 1 taken 55913 times.
100096 if(id < iLast)
9404 55913 strcpy(item_string[id],old_item_string[id]);
9405 100096 }
9406
9407 470 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9408 {
9409
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 24 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9410
9411 470 word weapons_to_read=MAXWPNS;
9412 int32_t dummy;
9413 byte padding;
9414 wpndata tempweapon;
9415 470 word s_version=0;
9416
9417
9418
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6 times.
470 if(Header->zelda_version < 0x186)
9419 {
9420 6 weapons_to_read=64;
9421 6 }
9422
9423
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6 times.
470 if(Header->zelda_version < 0x185)
9424 {
9425 6 weapons_to_read=32;
9426 6 }
9427
9428
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 446 times.
470 if(Header->zelda_version > 0x192)
9429 {
9430 446 weapons_to_read=0;
9431
9432 //section version info
9433
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&s_version,f))
9434 {
9435 return qe_invalid;
9436 }
9437
9438 446 FFCore.quest_format[vWeaponSprites] = s_version;
9439
9440
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!read_deprecated_section_cversion(f))
9441 {
9442 return qe_invalid;
9443 }
9444
9445 //section size
9446
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy,f))
9447 {
9448 return qe_invalid;
9449 }
9450
9451 //finally... section data
9452
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&weapons_to_read,f))
9453 {
9454 return qe_invalid;
9455 }
9456
9457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if (weapons_to_read > MAXWPNS)
9458 {
9459 return qe_invalid;
9460 }
9461 446 }
9462
9463
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 83 times.
470 if(s_version>2)
9464 {
9465
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i=0; i<weapons_to_read; i++)
9466 {
9467 char tempname[64];
9468
9469
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!pfread(tempname, 64, f))
9470 {
9471 return qe_invalid;
9472 }
9473
9474 99072 weapon_string[i][0] = '\0';
9475 99072 strncat(weapon_string[i], tempname, 64 - 1);
9476 99072 }
9477
9478
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version<4)
9479 {
9480 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9481 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9482 }
9483
9484
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version<5)
9485 {
9486 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9487 }
9488
9489 /*
9490 if (s_version<6)
9491 {
9492 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9493 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9494 }
9495 */
9496 387 }
9497
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9498 {
9499
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9500 20992 reset_weaponname(i);
9501 82 }
9502
9503
2/2
✓ Branch 0 taken 107884 times.
✓ Branch 1 taken 470 times.
108354 for(int32_t i=0; i<weapons_to_read; i++)
9504 {
9505 107884 word oldtile = 0;
9506
2/2
✓ Branch 0 taken 45312 times.
✓ Branch 1 taken 62572 times.
107884 if (s_version < 8)
9507 {
9508
1/2
✓ Branch 0 taken 62572 times.
✗ Branch 1 not taken.
62572 if (!p_igetw(&oldtile, f))
9509 return qe_invalid;
9510 62572 }
9511
9512
1/2
✓ Branch 0 taken 107884 times.
✗ Branch 1 not taken.
107884 if(!p_getc(&tempweapon.misc,f))
9513 {
9514 return qe_invalid;
9515 }
9516
9517
1/2
✓ Branch 0 taken 107884 times.
✗ Branch 1 not taken.
107884 if(!p_getc(&tempweapon.csets,f))
9518 {
9519 return qe_invalid;
9520 }
9521
9522
1/2
✓ Branch 0 taken 107884 times.
✗ Branch 1 not taken.
107884 if(!p_getc(&tempweapon.frames,f))
9523 {
9524 return qe_invalid;
9525 }
9526
9527
1/2
✓ Branch 0 taken 107884 times.
✗ Branch 1 not taken.
107884 if(!p_getc(&tempweapon.speed,f))
9528 {
9529 return qe_invalid;
9530 }
9531
9532
1/2
✓ Branch 0 taken 107884 times.
✗ Branch 1 not taken.
107884 if(!p_getc(&tempweapon.type,f))
9533 {
9534 return qe_invalid;
9535 }
9536
9537
2/2
✓ Branch 0 taken 61292 times.
✓ Branch 1 taken 46592 times.
107884 if ( s_version >= 7 )
9538 {
9539
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetw(&tempweapon.script,f))
9540 {
9541 return qe_invalid;
9542 }
9543
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempweapon.tile,f))
9544 {
9545 return qe_invalid;
9546 }
9547 46592 }
9548
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 61292 times.
107884 if ( s_version < 7 )
9549 {
9550 61292 tempweapon.tile = oldtile;
9551 61292 }
9552
9553
2/2
✓ Branch 0 taken 103084 times.
✓ Branch 1 taken 4800 times.
107884 if(Header->zelda_version < 0x193)
9554 {
9555
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9556 {
9557 return qe_invalid;
9558 }
9559 4800 }
9560
9561
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 8812 times.
107884 if(s_version < 6)
9562 {
9563
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9564 {
9565 18 tempweapon.misc |= WF_BEHIND;
9566 18 }
9567 else
9568 8794 tempweapon.misc &= ~WF_BEHIND;
9569 8812 }
9570
9571
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 107628 times.
107884 if (!should_skip)
9572 107628 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9573 107884 }
9574
9575
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 469 times.
470 if (should_skip)
9576 1 return 0;
9577
9578
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<2)
9579 {
9580 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9581 82 }
9582
9583
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<5)
9584 {
9585 82 wpnsbuf[iwQuarterHearts].tile=1;
9586 82 wpnsbuf[iwQuarterHearts].csets=1;
9587 82 }
9588
9589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(Header->zelda_version < 0x176)
9590 {
9591 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9592 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9593 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9594 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9595 }
9596
9597
3/4
✓ Branch 0 taken 451 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
474 if((Header->zelda_version < 0x192)||
9598
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 446 times.
451 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9599 {
9600 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9601 18 }
9602
9603
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 446 times.
469 if((Header->zelda_version < 0x210))
9604 {
9605 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9606 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9607 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9608 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9609 23 }
9610
9611 469 return 0;
9612 470 }
9613
9614 221721 static void guy_update_firesfx(guydata& tempguy)
9615 {
9616 221721 tempguy.firesfx = 0;
9617
2/2
✓ Branch 0 taken 6367 times.
✓ Branch 1 taken 215354 times.
221721 if (tempguy.family == eeWIZZ)
9618 {
9619
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
✓ Branch 2 taken 3891 times.
✓ Branch 3 taken 819 times.
✓ Branch 4 taken 692 times.
6367 switch (tempguy.attributes[1])
9620 {
9621 case 0: // normal weapon
9622 3891 tempguy.firesfx = WAV_WAND;
9623 3891 break;
9624 case 1: // 8 shots
9625
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 737 times.
819 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9626 else
9627 {
9628
3/8
✓ Branch 0 taken 634 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
737 switch (tempguy.weapon)
9629 {
9630 case ewFireTrail:
9631 case ewFlame:
9632 case ewFlame2Trail:
9633 case ewFlame2:
9634 634 tempguy.firesfx = WAV_FIRE;
9635 634 break;
9636 case ewWind:
9637 case ewMagic:
9638 87 tempguy.firesfx = WAV_WAND;
9639 87 break;
9640 case ewIce:
9641 tempguy.firesfx = WAV_ZN1ICE;
9642 break;
9643 case ewRock:
9644 tempguy.firesfx = WAV_ZN1ROCK;
9645 break;
9646 case ewFireball2:
9647 case ewFireball:
9648 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9649 16 break;
9650 case ewBrang:
9651 tempguy.firesfx = WAV_BRANG;
9652 break;
9653 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9654 tempguy.firesfx = WAV_BOMB;
9655 break;
9656 default:
9657 tempguy.firesfx = 0;
9658 break;
9659 }
9660 737 break;
9661 }
9662 case 2: // Summon
9663 1047 tempguy.firesfx = WAV_FIRE;
9664 1047 break;
9665 case 3: // Summon Layer
9666 692 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9667 692 break;
9668 }
9669 6367 }
9670 else
9671 {
9672
6/6
✓ Branch 0 taken 163151 times.
✓ Branch 1 taken 52203 times.
✓ Branch 2 taken 41491 times.
✓ Branch 3 taken 204642 times.
✓ Branch 4 taken 46849 times.
✓ Branch 5 taken 46845 times.
215354 if ((tempguy.family == eeWALK || tempguy.family == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
9673 {
9674 93694 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9675 93694 }
9676 else
9677 {
9678
7/8
✓ Branch 0 taken 9515 times.
✓ Branch 1 taken 2333 times.
✓ Branch 2 taken 1790 times.
✓ Branch 3 taken 12698 times.
✓ Branch 4 taken 172141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3921 times.
✓ Branch 7 taken 2244 times.
204642 switch (tempguy.weapon)
9679 {
9680 case ewFireTrail:
9681 case ewFlame:
9682 case ewFlame2Trail:
9683 case ewFlame2:
9684 9515 tempguy.firesfx = WAV_FIRE;
9685 9515 break;
9686 case ewWind:
9687 case ewMagic:
9688 1790 tempguy.firesfx = WAV_WAND;
9689 1790 break;
9690 case ewIce:
9691 tempguy.firesfx = WAV_ZN1ICE;
9692 break;
9693 case ewRock:
9694 3921 tempguy.firesfx = WAV_ZN1ROCK;
9695 3921 break;
9696 case ewFireball2:
9697 case ewFireball:
9698 12698 tempguy.firesfx = WAV_ZN1FIREBALL;
9699 12698 break;
9700 case ewBrang:
9701 2244 tempguy.firesfx = WAV_BRANG;
9702 2244 break;
9703 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9704 2333 tempguy.firesfx = WAV_BOMB;
9705 2333 break;
9706 default:
9707 172141 tempguy.firesfx = 0;
9708 172141 break;
9709 }
9710 }
9711 }
9712 211013 }
9713
9714 211013 static void guy_update_weaponflags(guydata& tempguy)
9715 {
9716 211013 tempguy.wunblockable = 0;
9717 211013 tempguy.wmoveflags = move_none;
9718
4/4
✓ Branch 0 taken 204557 times.
✓ Branch 1 taken 6456 times.
✓ Branch 2 taken 2970 times.
✓ Branch 3 taken 201587 times.
211013 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
9719 9426 tempguy.wmoveflags |= (move_obeys_grav | move_can_pitfall);
9720 211013 tempguy.weapoverrideFLAGS = 0;
9721 211013 tempguy.weap_hxofs = 0;
9722 211013 tempguy.weap_hyofs = 0;
9723 211013 tempguy.weap_hxsz = 0;
9724 211013 tempguy.weap_hysz = 0;
9725 211013 tempguy.weap_hzsz = 0;
9726 211013 tempguy.weap_xofs = 0;
9727 211013 tempguy.weap_yofs = 0;
9728 211013 tempguy.weap_tilew = 0;
9729 211013 tempguy.weap_tileh = 0;
9730
5/5
✓ Branch 0 taken 2483 times.
✓ Branch 1 taken 170179 times.
✓ Branch 2 taken 18333 times.
✓ Branch 3 taken 12714 times.
✓ Branch 4 taken 7304 times.
211013 switch (tempguy.weapon)
9731 {
9732 case ewFireball: case ewFireball2:
9733 12714 tempguy.wstep = 175;
9734 12714 break;
9735 case ewSword: case ewLitBomb: case ewLitSBomb:
9736 case ewRock: case ewMagic: case ewWind:
9737 18333 tempguy.wstep = 300;
9738 18333 break;
9739 case ewArrow:
9740 2483 tempguy.wstep = 200;
9741 2483 break;
9742 case ewFlame: case ewFlame2:
9743 7304 tempguy.wstep = 100;
9744 7304 break;
9745 default:
9746 170179 tempguy.wstep = 0;
9747 170179 break;
9748 }
9749
2/2
✓ Branch 0 taken 1055065 times.
✓ Branch 1 taken 211013 times.
1266078 for (int q = 0; q < WPNSPR_MAX; ++q)
9750 {
9751 1055065 tempguy.burnsprs[q] = 0;
9752 1055065 tempguy.light_rads[q] = 0;
9753 1055065 }
9754 211013 }
9755
9756 211013 static void guy_update_weaponspecialsfx(guydata& tempguy)
9757 {
9758
3/3
✓ Branch 0 taken 2244 times.
✓ Branch 1 taken 206381 times.
✓ Branch 2 taken 2388 times.
211013 switch (tempguy.weapon)
9759 {
9760 case ewBrang:
9761 2244 tempguy.specialsfx = WAV_BRANG;
9762 2244 break;
9763 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
9764 2388 tempguy.specialsfx = WAV_BOMB;
9765 2388 break;
9766 default:
9767 206381 tempguy.specialsfx = 0;
9768 206381 break;
9769 }
9770 211013 }
9771
9772 469 void init_guys(int32_t guyversion)
9773 {
9774
2/2
✓ Branch 0 taken 240128 times.
✓ Branch 1 taken 469 times.
240597 for(int32_t i=0; i<MAXGUYS; i++)
9775 {
9776 240128 guysbuf[i] = default_guys[0];
9777 240128 }
9778
9779
2/2
✓ Branch 0 taken 83013 times.
✓ Branch 1 taken 469 times.
83482 for(int32_t i=0; i<OLDMAXGUYS; i++)
9780 {
9781 83013 guysbuf[i] = default_guys[i];
9782
2/2
✓ Branch 0 taken 82075 times.
✓ Branch 1 taken 938 times.
83013 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9783 83013 guysbuf[i].spr_death = iwDeath;
9784 83013 guysbuf[i].spr_spawn = iwSpawn;
9785 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9786
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 68499 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
83013 if(guyversion<=3 && i==ePATRABS)
9787 {
9788 82 guysbuf[i].bosspal=spDIG;
9789 82 guysbuf[i].cset=14;
9790 82 guysbuf[i].attributes[8] = 14;
9791 82 }
9792
9793
2/2
✓ Branch 0 taken 68499 times.
✓ Branch 1 taken 14514 times.
83013 if(guyversion<=3)
9794 {
9795 // Rope/Ghini Flash rules
9796
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9797 {
9798
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9799 {
9800 59 guysbuf[i].flags &= ~guy_flashing;
9801 59 }
9802 10443 }
9803
9804
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9805 {
9806
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9807 {
9808 72 guysbuf[i].flags &= ~guy_flashing;
9809 72 }
9810 2124 }
9811
9812
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
9813 {
9814
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9815 {
9816 4 guysbuf[i].flags |= guy_blinking;
9817 4 }
9818
9819
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9820 {
9821 38 guysbuf[i].flags |= guy_transparent;
9822 38 }
9823 82 }
9824
9825
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
9826 {
9827 164 guysbuf[i].flags |= guy_ignore_kill_all;
9828 164 }
9829 14514 }
9830
9831 // Darknut fix
9832
10/10
✓ Branch 0 taken 82544 times.
✓ Branch 1 taken 469 times.
✓ Branch 2 taken 82075 times.
✓ Branch 3 taken 469 times.
✓ Branch 4 taken 81606 times.
✓ Branch 5 taken 469 times.
✓ Branch 6 taken 81137 times.
✓ Branch 7 taken 469 times.
✓ Branch 8 taken 469 times.
✓ Branch 9 taken 80668 times.
83013 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9833 {
9834
2/2
✓ Branch 0 taken 1940 times.
✓ Branch 1 taken 405 times.
2345 if(get_qr(qr_NEWENEMYTILES))
9835 {
9836 1940 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9837 1940 guysbuf[i].s_width=guysbuf[i].e_width;
9838 1940 guysbuf[i].s_height=guysbuf[i].e_height;
9839 1940 }
9840 405 else guysbuf[i].s_tile=860;
9841
9842
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2025 times.
2345 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9843 2025 guysbuf[i].flags &= ~guy_bkshield;
9844 else
9845 320 guysbuf[i].flags |= guy_bkshield;
9846 2345 }
9847
9848
4/4
✓ Branch 0 taken 82544 times.
✓ Branch 1 taken 469 times.
✓ Branch 2 taken 82963 times.
✓ Branch 3 taken 50 times.
83013 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9849 {
9850 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
9851 50 }
9852
9853 83013 guy_update_firesfx(guysbuf[i]);
9854 83013 guy_update_weaponflags(guysbuf[i]);
9855 83013 guy_update_weaponspecialsfx(guysbuf[i]);
9856 83013 }
9857 469 }
9858
9859 20992 void reset_weaponname(int32_t i)
9860 {
9861
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
9862 {
9863 7216 strcpy(weapon_string[i],old_weapon_string[i]);
9864 7216 }
9865 else
9866 13776 sprintf(weapon_string[i],"zz%03d",i);
9867 20992 }
9868
9869 469 void init_item_drop_sets()
9870 {
9871
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9872 {
9873 // item_drop_sets[i] = default_item_drop_sets[0];
9874 120064 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9875 120064 }
9876
9877
2/2
✓ Branch 0 taken 6097 times.
✓ Branch 1 taken 469 times.
6566 for(int32_t i=0; i<isMAX; i++)
9878 {
9879 6097 item_drop_sets[i] = default_item_drop_sets[i];
9880
9881 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9882
2/2
✓ Branch 0 taken 60970 times.
✓ Branch 1 taken 6097 times.
67067 for(int32_t j=0; j<10; ++j)
9883 {
9884 60970 int32_t it = item_drop_sets[i].item[j];
9885
9886
3/4
✓ Branch 0 taken 42872 times.
✓ Branch 1 taken 18098 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2766 times.
60970 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9887
2/2
✓ Branch 0 taken 2766 times.
✓ Branch 1 taken 40106 times.
42872 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9888 {
9889 2766 item_drop_sets[i].chance[j+1]=0;
9890 2766 }
9891
4/4
✓ Branch 0 taken 1876 times.
✓ Branch 1 taken 56328 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1732 times.
58204 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9892 {
9893 144 item_drop_sets[i].chance[j+1]=0;
9894 144 }
9895
9896 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9897
2/2
✓ Branch 0 taken 60946 times.
✓ Branch 1 taken 24 times.
60970 if(itemsbuf[it].family == itype_misc)
9898 {
9899 // If a non-gameplay item was selected, then item drop was aborted.
9900 // Reflect this by increasing the 'Nothing' chance accordingly.
9901 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9902 24 item_drop_sets[i].chance[j+1]=0;
9903 24 }
9904 60970 }
9905 6097 }
9906 469 }
9907
9908 469 void init_favorites()
9909 {
9910
2/2
✓ Branch 0 taken 590940 times.
✓ Branch 1 taken 469 times.
591409 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9911 {
9912 590940 favorite_combos[i]=-1;
9913 590940 }
9914 469 }
9915
9916 const char *ctype_name[cMAX]=
9917 {
9918 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9919 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9920 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9921 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9922 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9923 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9924 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9925 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9926 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9927 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9928 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9929 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9930 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9931 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9932 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9933 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9934 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9935 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9936 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9937 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9938 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9939 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9940 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9941 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9942 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9943 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9944 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9945 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9946
9947 };
9948
9949 761 int32_t init_combo_classes()
9950 {
9951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 761 times.
761 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9952
2/2
✓ Branch 0 taken 139263 times.
✓ Branch 1 taken 761 times.
140024 for(int32_t i=0; i<cMAX; i++)
9953 {
9954 139263 combo_class_buf[i] = default_combo_classes[i];
9955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139263 times.
139263 if ( char const* nm = zi->getComboTypeName(i) )
9956 {
9957 139263 size_t len = strlen(nm);
9958
2/2
✓ Branch 0 taken 8912832 times.
✓ Branch 1 taken 139263 times.
9052095 for ( size_t q = 0; q < 64; q++ )
9959 {
9960
2/2
✓ Branch 0 taken 2040241 times.
✓ Branch 1 taken 6872591 times.
8912832 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9961 8912832 }
9962 139263 }
9963 139263 }
9964
9965 761 return 0;
9966 }
9967
9968 310 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
9969 {
9970
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 264 times.
310 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if (should_skip) return 0;
9972
9973
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 assert(v_herosprites < 6);
9974
9975 310 zinit.hero_swim_speed=67; //default
9976 310 setupherotiles(zinit.heroAnimationStyle);
9977 310 setupherodefenses();
9978 310 setupherooffsets();
9979
9980
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 205 times.
310 if(v_herosprites>=0)
9981 {
9982 word tile, tile2;
9983 byte flip, extend, dummy_byte;
9984
9985
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
9986 {
9987
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
9988 {
9989 return qe_invalid;
9990 }
9991
9992
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
9993 {
9994 return qe_invalid;
9995 }
9996
9997
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
9998 {
9999 return qe_invalid;
10000 }
10001
10002 820 walkspr[i][spr_tile]=(int32_t)tile;
10003 820 walkspr[i][spr_flip]=(int32_t)flip;
10004 820 walkspr[i][spr_extend]=(int32_t)extend;
10005 820 }
10006
10007
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10008 {
10009
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10010 {
10011 return qe_invalid;
10012 }
10013
10014
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10015 {
10016 return qe_invalid;
10017 }
10018
10019
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10020 {
10021 return qe_invalid;
10022 }
10023
10024 820 stabspr[i][spr_tile]=(int32_t)tile;
10025 820 stabspr[i][spr_flip]=(int32_t)flip;
10026 820 stabspr[i][spr_extend]=(int32_t)extend;
10027 820 }
10028
10029
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10030 {
10031
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10032 {
10033 return qe_invalid;
10034 }
10035
10036
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10037 {
10038 return qe_invalid;
10039 }
10040
10041
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10042 {
10043 return qe_invalid;
10044 }
10045
10046 820 slashspr[i][spr_tile]=(int32_t)tile;
10047 820 slashspr[i][spr_flip]=(int32_t)flip;
10048 820 slashspr[i][spr_extend]=(int32_t)extend;
10049 820 }
10050
10051
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10052 {
10053
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10054 {
10055 return qe_invalid;
10056 }
10057
10058
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10059 {
10060 return qe_invalid;
10061 }
10062
10063
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10064 {
10065 return qe_invalid;
10066 }
10067
10068 820 floatspr[i][spr_tile]=(int32_t)tile;
10069 820 floatspr[i][spr_flip]=(int32_t)flip;
10070 820 floatspr[i][spr_extend]=(int32_t)extend;
10071 820 }
10072
10073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>1)
10074 {
10075
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10076 {
10077
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10078 {
10079 return qe_invalid;
10080 }
10081
10082
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10083 {
10084 return qe_invalid;
10085 }
10086
10087
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10088 {
10089 return qe_invalid;
10090 }
10091
10092 820 swimspr[i][spr_tile]=(int32_t)tile;
10093 820 swimspr[i][spr_flip]=(int32_t)flip;
10094 820 swimspr[i][spr_extend]=(int32_t)extend;
10095 820 }
10096 205 }
10097
10098
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10099 {
10100
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10101 {
10102 return qe_invalid;
10103 }
10104
10105
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10106 {
10107 return qe_invalid;
10108 }
10109
10110
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10111 {
10112 return qe_invalid;
10113 }
10114
10115 820 divespr[i][spr_tile]=(int32_t)tile;
10116 820 divespr[i][spr_flip]=(int32_t)flip;
10117 820 divespr[i][spr_extend]=(int32_t)extend;
10118 820 }
10119
10120
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10121 {
10122
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10123 {
10124 return qe_invalid;
10125 }
10126
10127
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10128 {
10129 return qe_invalid;
10130 }
10131
10132
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10133 {
10134 return qe_invalid;
10135 }
10136
10137 820 poundspr[i][spr_tile]=(int32_t)tile;
10138 820 poundspr[i][spr_flip]=(int32_t)flip;
10139 820 poundspr[i][spr_extend]=(int32_t)extend;
10140 820 }
10141
10142
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&tile,f))
10143 {
10144 return qe_invalid;
10145 }
10146
10147 205 flip=0;
10148
10149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>0)
10150 {
10151
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&flip,f))
10152 {
10153 return qe_invalid;
10154 }
10155 205 }
10156
10157
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&extend,f))
10158 {
10159 return qe_invalid;
10160 }
10161
10162 205 castingspr[spr_tile]=(int32_t)tile;
10163 205 castingspr[spr_flip]=(int32_t)flip;
10164 205 castingspr[spr_extend]=(int32_t)extend;
10165
10166
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(v_herosprites>0)
10167 {
10168 205 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10169
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 205 times.
615 for(int32_t i=0; i<2; i++)
10170 {
10171
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 410 times.
1230 for(int32_t j=0; j<num_holdsprs; j++)
10172 {
10173
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10174 {
10175 return qe_invalid;
10176 }
10177
10178
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10179 {
10180 return qe_invalid;
10181 }
10182
10183
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10184 {
10185 return qe_invalid;
10186 }
10187
10188 820 holdspr[i][j][spr_tile]=(int32_t)tile;
10189 820 holdspr[i][j][spr_flip]=(int32_t)flip;
10190 820 holdspr[i][j][spr_extend]=(int32_t)extend;
10191 820 }
10192 410 }
10193 205 }
10194 else
10195 {
10196 for(int32_t i=0; i<2; i++)
10197 {
10198 if(!p_igetw(&tile,f))
10199 {
10200 return qe_invalid;
10201 }
10202
10203 if(!p_igetw(&tile2,f))
10204 {
10205 return qe_invalid;
10206 }
10207
10208 if(!p_getc(&extend,f))
10209 {
10210 return qe_invalid;
10211 }
10212
10213 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10214 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10215 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10216 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10217 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10218 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10219 }
10220 }
10221
10222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>2)
10223 {
10224
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10225 {
10226
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10227 {
10228 return qe_invalid;
10229 }
10230
10231
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10232 {
10233 return qe_invalid;
10234 }
10235
10236
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10237 {
10238 return qe_invalid;
10239 }
10240
10241 820 jumpspr[i][spr_tile]=(int32_t)tile;
10242 820 jumpspr[i][spr_flip]=(int32_t)flip;
10243 820 jumpspr[i][spr_extend]=(int32_t)extend;
10244 820 }
10245 205 }
10246
10247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>3)
10248 {
10249
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10250 {
10251
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10252 {
10253 return qe_invalid;
10254 }
10255
10256
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10257 {
10258 return qe_invalid;
10259 }
10260
10261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(!p_getc(&extend,f))
10262 {
10263 return qe_invalid;
10264 }
10265
10266 820 chargespr[i][spr_tile]=(int32_t)tile;
10267 820 chargespr[i][spr_flip]=(int32_t)flip;
10268 820 chargespr[i][spr_extend]=(int32_t)extend;
10269 820 }
10270 205 }
10271
10272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>4)
10273 {
10274
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&dummy_byte,f))
10275 {
10276 return qe_invalid;
10277 }
10278
10279 205 zinit.hero_swim_speed=(byte)dummy_byte;
10280 205 }
10281
10282 205 memset(frozenspr, 0, sizeof(frozenspr));
10283 205 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10284 205 memset(onfirespr, 0, sizeof(onfirespr));
10285 205 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10286 205 memset(diggingspr, 0, sizeof(diggingspr));
10287 205 memset(usingrodspr, 0, sizeof(usingrodspr));
10288 205 memset(usingcanespr, 0, sizeof(usingcanespr));
10289 205 memset(pushingspr, 0, sizeof(pushingspr));
10290 205 memset(liftingspr, 0, sizeof(liftingspr));
10291 205 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10292 205 memset(stunnedspr, 0, sizeof(stunnedspr));
10293 205 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10294 205 memset(fallingspr, 0, sizeof(fallingspr));
10295 205 memset(shockedspr, 0, sizeof(shockedspr));
10296 205 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10297 205 memset(pullswordspr, 0, sizeof(pullswordspr));
10298 205 memset(readingspr, 0, sizeof(readingspr));
10299 205 memset(slash180spr, 0, sizeof(slash180spr));
10300 205 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10301 205 memset(dashspr, 0, sizeof(dashspr));
10302 205 memset(bonkspr, 0, sizeof(bonkspr));
10303 205 memset(medallionsprs, 0, sizeof(medallionsprs));
10304 205 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10305 205 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10306
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t q = 0; q < 4; ++q)
10307 {
10308
2/2
✓ Branch 0 taken 2460 times.
✓ Branch 1 taken 820 times.
3280 for(int32_t p = 0; p < 3; ++p)
10309 {
10310 2460 drowningspr[q][p] = divespr[q][p];
10311 2460 drowning_lavaspr[q][p] = divespr[q][p];
10312 2460 }
10313 820 }
10314 205 memset(sideswimspr, 0, sizeof(sideswimspr));
10315 205 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10316 205 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10317 205 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10318 205 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10319 205 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10320 205 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10321 205 }
10322
10323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if(FFCore.quest_format[vInitData] < 34)
10324 {
10325 310 bool fastswim = zinit.hero_swim_speed > 60;
10326 // '2/3' or '1/2'
10327 310 zinit.hero_swim_mult = fastswim ? 2 : 1;
10328 310 zinit.hero_swim_div = fastswim ? 3 : 2;
10329 310 }
10330 310 return 0;
10331 310 }
10332
10333 30940 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10334 {
10335 30940 arr[spr_tile] = tile;
10336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30940 times.
30940 arr[spr_flip] = (flip > 3 ? 0 : flip);
10337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30940 times.
30940 arr[spr_extend] = (ext > 2 ? 0 : ext);
10338 30940 }
10339 //Used to read the player sprites as int32_t, not word.
10340 182 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10341 {
10342 182 zinit.hero_swim_speed=67; //default
10343 182 setupherotiles(zinit.heroAnimationStyle);
10344 182 setupherodefenses();
10345 182 setupherooffsets();
10346
10347 int32_t tile, tile2;
10348 byte flip, extend, dummy_byte;
10349
10350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>=0)
10351 {
10352
10353
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10354 {
10355
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10356 {
10357 return qe_invalid;
10358 }
10359
10360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10361 {
10362 return qe_invalid;
10363 }
10364
10365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10366 {
10367 return qe_invalid;
10368 }
10369
10370 728 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10371 728 }
10372
10373
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10374 {
10375
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10376 {
10377 return qe_invalid;
10378 }
10379
10380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10381 {
10382 return qe_invalid;
10383 }
10384
10385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10386 {
10387 return qe_invalid;
10388 }
10389
10390 728 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10391 728 }
10392
10393
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10394 {
10395
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10396 {
10397 return qe_invalid;
10398 }
10399
10400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10401 {
10402 return qe_invalid;
10403 }
10404
10405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10406 {
10407 return qe_invalid;
10408 }
10409
10410 728 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10411 728 }
10412
10413
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10414 {
10415
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10416 {
10417 return qe_invalid;
10418 }
10419
10420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10421 {
10422 return qe_invalid;
10423 }
10424
10425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10426 {
10427 return qe_invalid;
10428 }
10429
10430 728 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10431 728 }
10432
10433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>1)
10434 {
10435
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10436 {
10437
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10438 {
10439 return qe_invalid;
10440 }
10441
10442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10443 {
10444 return qe_invalid;
10445 }
10446
10447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10448 {
10449 return qe_invalid;
10450 }
10451
10452 728 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10453 728 }
10454 182 }
10455
10456
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10457 {
10458
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10459 {
10460 return qe_invalid;
10461 }
10462
10463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10464 {
10465 return qe_invalid;
10466 }
10467
10468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10469 {
10470 return qe_invalid;
10471 }
10472
10473 728 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10474 728 }
10475
10476
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10477 {
10478
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10479 {
10480 return qe_invalid;
10481 }
10482
10483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10484 {
10485 return qe_invalid;
10486 }
10487
10488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10489 {
10490 return qe_invalid;
10491 }
10492
10493 728 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10494 728 }
10495
10496
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&tile,f))
10497 {
10498 return qe_invalid;
10499 }
10500
10501 182 flip=0;
10502
10503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>0)
10504 {
10505
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_getc(&flip,f))
10506 {
10507 return qe_invalid;
10508 }
10509 182 }
10510
10511
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_getc(&extend,f))
10512 {
10513 return qe_invalid;
10514 }
10515
10516 182 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10517
10518
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(v_herosprites>0)
10519 {
10520 182 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10521
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 182 times.
546 for(int32_t i=0; i<2; i++)
10522 {
10523
2/2
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 364 times.
1456 for(int32_t j=0; j<num_holdsprs; j++)
10524 {
10525
1/2
✓ Branch 0 taken 1092 times.
✗ Branch 1 not taken.
1092 if(!p_igetl(&tile,f))
10526 {
10527 return qe_invalid;
10528 }
10529
10530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if(!p_getc(&flip,f))
10531 {
10532 return qe_invalid;
10533 }
10534
10535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if(!p_getc(&extend,f))
10536 {
10537 return qe_invalid;
10538 }
10539
10540 1092 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10541 1092 }
10542 364 }
10543 182 }
10544 else
10545 {
10546 for(int32_t i=0; i<2; i++)
10547 {
10548 if(!p_igetl(&tile,f))
10549 {
10550 return qe_invalid;
10551 }
10552
10553 if(!p_igetl(&tile2,f))
10554 {
10555 return qe_invalid;
10556 }
10557
10558 if(!p_getc(&extend,f))
10559 {
10560 return qe_invalid;
10561 }
10562
10563 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10564 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10565 }
10566 }
10567
10568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>2)
10569 {
10570
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10571 {
10572
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10573 {
10574 return qe_invalid;
10575 }
10576
10577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10578 {
10579 return qe_invalid;
10580 }
10581
10582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10583 {
10584 return qe_invalid;
10585 }
10586
10587 728 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10588 728 }
10589 182 }
10590
10591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>3)
10592 {
10593
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10594 {
10595
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10596 {
10597 return qe_invalid;
10598 }
10599
10600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10601 {
10602 return qe_invalid;
10603 }
10604
10605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10606 {
10607 return qe_invalid;
10608 }
10609
10610 728 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10611 728 }
10612 182 }
10613
10614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>4)
10615 {
10616
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_getc(&dummy_byte,f))
10617 {
10618 return qe_invalid;
10619 }
10620
10621 182 zinit.hero_swim_speed=(byte)dummy_byte;
10622 182 }
10623
10624
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(v_herosprites>6)
10625 {
10626
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10627 {
10628
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10629 return qe_invalid;
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10632 return qe_invalid;
10633
10634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10635 return qe_invalid;
10636
10637 728 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10638 728 }
10639
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10640 {
10641
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10642 return qe_invalid;
10643
10644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10645 return qe_invalid;
10646
10647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10648 return qe_invalid;
10649
10650 728 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10651 728 }
10652
10653
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10654 {
10655
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10656 return qe_invalid;
10657
10658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10659 return qe_invalid;
10660
10661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10662 return qe_invalid;
10663
10664 728 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10665 728 }
10666
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10667 {
10668
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10669 return qe_invalid;
10670
10671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10672 return qe_invalid;
10673
10674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10675 return qe_invalid;
10676
10677 728 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10678 728 }
10679
10680
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10681 {
10682
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10683 return qe_invalid;
10684
10685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10686 return qe_invalid;
10687
10688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10689 return qe_invalid;
10690
10691 728 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10692 728 }
10693
10694
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10695 {
10696
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10697 return qe_invalid;
10698
10699
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10700 return qe_invalid;
10701
10702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10703 return qe_invalid;
10704
10705 728 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10706 728 }
10707
10708
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10709 {
10710
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10711 return qe_invalid;
10712
10713
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10714 return qe_invalid;
10715
10716
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10717 return qe_invalid;
10718
10719 728 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10720 728 }
10721
10722
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10723 {
10724
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10725 return qe_invalid;
10726
10727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10728 return qe_invalid;
10729
10730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10731 return qe_invalid;
10732
10733 728 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10734 728 }
10735
10736
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10737 {
10738
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10739 return qe_invalid;
10740
10741
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10742 return qe_invalid;
10743
10744
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10745 return qe_invalid;
10746
10747 728 byte frames = 0;
10748
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 708 times.
728 if(v_herosprites > 15)
10749 {
10750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708 times.
708 if(!p_getc(&frames,f))
10751 return qe_invalid;
10752 708 }
10753
10754 728 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10755 728 liftingspr[q][spr_frames] = frames;
10756 728 }
10757
10758
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10759 {
10760
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10761 return qe_invalid;
10762
10763
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10764 return qe_invalid;
10765
10766
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10767 return qe_invalid;
10768
10769 728 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10770 728 }
10771
10772
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10773 {
10774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_igetl(&tile,f))
10775 return qe_invalid;
10776
10777
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10778 return qe_invalid;
10779
10780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10781 return qe_invalid;
10782
10783 728 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10784 728 }
10785
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10786 {
10787
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10788 return qe_invalid;
10789
10790
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10791 return qe_invalid;
10792
10793
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10794 return qe_invalid;
10795
10796 728 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10797 728 }
10798
10799
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10800 {
10801
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10802 return qe_invalid;
10803
10804
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10805 return qe_invalid;
10806
10807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10808 return qe_invalid;
10809
10810 728 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10811 728 }
10812
10813
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10814 {
10815
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10816 return qe_invalid;
10817
10818
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10819 return qe_invalid;
10820
10821
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10822 return qe_invalid;
10823
10824 728 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10825 728 }
10826
10827
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10828 {
10829
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10830 return qe_invalid;
10831
10832
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10833 return qe_invalid;
10834
10835
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10836 return qe_invalid;
10837
10838 728 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10839 728 }
10840
10841
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10842 {
10843
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10844 return qe_invalid;
10845
10846
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10847 return qe_invalid;
10848
10849
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10850 return qe_invalid;
10851
10852 728 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10853 728 }
10854
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10855 {
10856
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10857 return qe_invalid;
10858
10859
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10860 return qe_invalid;
10861
10862
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10863 return qe_invalid;
10864
10865 728 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10866 728 }
10867
10868
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10869 {
10870
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10871 return qe_invalid;
10872
10873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10874 return qe_invalid;
10875
10876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10877 return qe_invalid;
10878
10879 728 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10880 728 }
10881
10882
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10883 {
10884
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10885 return qe_invalid;
10886
10887
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10888 return qe_invalid;
10889
10890
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10891 return qe_invalid;
10892
10893 728 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10894 728 }
10895
10896
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10897 {
10898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_igetl(&tile,f))
10899 return qe_invalid;
10900
10901
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10902 return qe_invalid;
10903
10904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10905 return qe_invalid;
10906
10907 728 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10908 728 }
10909
10910
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10911 {
10912
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10913 return qe_invalid;
10914
10915
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10916 return qe_invalid;
10917
10918
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10919 return qe_invalid;
10920
10921 728 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10922 728 }
10923
10924
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10925 {
10926
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10927 return qe_invalid;
10928
10929
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10930 return qe_invalid;
10931
10932
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10933 return qe_invalid;
10934
10935 728 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10936 728 }
10937
10938
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10939 {
10940
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10941 return qe_invalid;
10942
10943
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10944 return qe_invalid;
10945
10946
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10947 return qe_invalid;
10948
10949 728 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10950 728 }
10951
10952
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 182 times.
728 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10953 {
10954
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if(!p_igetl(&tile,f))
10955 return qe_invalid;
10956
10957
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if(!p_getc(&flip,f))
10958 return qe_invalid;
10959
10960
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if(!p_getc(&extend,f))
10961 return qe_invalid;
10962
10963 546 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10964 546 }
10965 182 }
10966 else
10967 {
10968 memset(frozenspr, 0, sizeof(frozenspr));
10969 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10970 memset(onfirespr, 0, sizeof(onfirespr));
10971 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10972 memset(diggingspr, 0, sizeof(diggingspr));
10973 memset(usingrodspr, 0, sizeof(usingrodspr));
10974 memset(usingcanespr, 0, sizeof(usingcanespr));
10975 memset(pushingspr, 0, sizeof(pushingspr));
10976 memset(liftingspr, 0, sizeof(liftingspr));
10977 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10978 memset(stunnedspr, 0, sizeof(stunnedspr));
10979 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10980 memset(fallingspr, 0, sizeof(fallingspr));
10981 memset(shockedspr, 0, sizeof(shockedspr));
10982 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10983 memset(pullswordspr, 0, sizeof(pullswordspr));
10984 memset(readingspr, 0, sizeof(readingspr));
10985 memset(slash180spr, 0, sizeof(slash180spr));
10986 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10987 memset(dashspr, 0, sizeof(dashspr));
10988 memset(bonkspr, 0, sizeof(bonkspr));
10989 memset(medallionsprs, 0, sizeof(medallionsprs));
10990 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10991 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10992 for(int32_t q = 0; q < 4; ++q)
10993 {
10994 for(int32_t p = 0; p < 3; ++p)
10995 {
10996 drowningspr[q][p] = divespr[q][p];
10997 drowning_lavaspr[q][p] = divespr[q][p];
10998 }
10999 }
11000 }
11001
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 8)
11002 {
11003
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11004 {
11005
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11006 return qe_invalid;
11007
11008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11009 return qe_invalid;
11010
11011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11012 return qe_invalid;
11013
11014 728 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11015 728 }
11016 182 }
11017 else
11018 {
11019 memset(sideswimspr, 0, sizeof(sideswimspr));
11020 }
11021
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 9)
11022 {
11023
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11024 {
11025
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11026 return qe_invalid;
11027
11028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11029 return qe_invalid;
11030
11031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11032 return qe_invalid;
11033
11034 728 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11035 728 }
11036
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11037 {
11038
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11039 return qe_invalid;
11040
11041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11042 return qe_invalid;
11043
11044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11045 return qe_invalid;
11046
11047 728 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11048 728 }
11049
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11050 {
11051
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11052 return qe_invalid;
11053
11054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11055 return qe_invalid;
11056
11057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11058 return qe_invalid;
11059
11060 728 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11061 728 }
11062
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11063 {
11064
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11065 return qe_invalid;
11066
11067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11068 return qe_invalid;
11069
11070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11071 return qe_invalid;
11072
11073 728 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11074 728 }
11075 182 }
11076 else
11077 {
11078 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11079 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11080 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11081 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11082 }
11083
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 10)
11084 {
11085
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11086 {
11087 int32_t hmr;
11088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_igetl(&hmr,f))
11089 return qe_invalid;
11090
11091 728 hammeroffsets[q] = hmr;
11092 728 }
11093 182 }
11094 else
11095 {
11096 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11097 }
11098
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 11)
11099 {
11100
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 182 times.
728 for(int32_t q = 0; q < 3; ++q)
11101 {
11102
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if(!p_igetl(&tile,f))
11103 return qe_invalid;
11104
11105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if(!p_getc(&flip,f))
11106 return qe_invalid;
11107
11108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if(!p_getc(&extend,f))
11109 return qe_invalid;
11110
11111 546 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11112 546 }
11113 182 }
11114 else
11115 {
11116 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11117 }
11118
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 12)
11119 {
11120
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&tile,f))
11121 return qe_invalid;
11122
11123
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_getc(&flip,f))
11124 return qe_invalid;
11125
11126
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_getc(&extend,f))
11127 return qe_invalid;
11128 182 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11129
11130 182 }
11131 else
11132 {
11133 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11134 }
11135
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 13)
11136 {
11137
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11138 {
11139
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11140 return qe_invalid;
11141
11142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11143 return qe_invalid;
11144
11145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11146 return qe_invalid;
11147
11148 728 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11149 728 }
11150 182 }
11151 else
11152 {
11153 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11154 }
11155
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 14)
11156 {
11157
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11158 {
11159
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11160 return qe_invalid;
11161
11162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11163 return qe_invalid;
11164
11165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11166 return qe_invalid;
11167
11168 728 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11169 728 }
11170 182 }
11171 else
11172 {
11173 memset(revslashspr, 0, sizeof(revslashspr));
11174 }
11175
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 7)
11176 {
11177 182 int32_t num_defense = wMax;
11178 182 byte def = 0;
11179
11180 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11181 /*if(v_herosprites > [x])
11182 * {
11183 * num_defense = 146 //value of wMax on version 8
11184 * }
11185 */
11186
11187
2/2
✓ Branch 0 taken 26572 times.
✓ Branch 1 taken 182 times.
26754 for (int32_t q = 0; q < num_defense; q++)
11188 {
11189
1/2
✓ Branch 0 taken 26572 times.
✗ Branch 1 not taken.
26572 if (!p_getc(&def, f))
11190 return qe_invalid;
11191
11192 26572 hero_defenses[q] = def;
11193 26572 }
11194 182 }
11195 else
11196 {
11197 int32_t num_defense = wMax;
11198 for (int32_t q = 0; q < num_defense; q++)
11199 {
11200 hero_defenses[q] = 0;
11201 }
11202 }
11203 182 }
11204
11205
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 11 times.
182 if(FFCore.quest_format[vInitData] < 34)
11206 {
11207 11 bool fastswim = zinit.hero_swim_speed > 60;
11208 // '2/3' or '1/2'
11209 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11210 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11211 11 }
11212 182 return 0;
11213 182 }
11214
11215
11216 387 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11217 {
11218 //these are here to bypass compiler warnings about unused arguments
11219 387 Header=Header;
11220
11221 dword dummy;
11222 387 word s_version=0;
11223
11224 //section version info
11225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&s_version,f))
11226 {
11227 return qe_invalid;
11228 }
11229
11230 387 FFCore.quest_format[vHeroSprites] = s_version;
11231
11232
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
11233 {
11234 return qe_invalid;
11235 }
11236
11237 //section size
11238
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy,f))
11239 {
11240 return qe_invalid;
11241 }
11242
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if ( s_version >= 6 )
11243 {
11244 182 return readherosprites3(f, s_version);
11245 }
11246 205 else return readherosprites2(f, s_version);
11247 387 }
11248
11249 222 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11250 {
11251 222 subscreens_active.clear();
11252 222 subscreens_passive.clear();
11253 222 subscreens_overlay.clear();
11254
2/2
✓ Branch 0 taken 28416 times.
✓ Branch 1 taken 222 times.
28638 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11255 {
11256 subscreen_group g;
11257 28416 memset(&g,0,sizeof(subscreen_group));
11258 28416 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(ret!=0)
11260 return ret;
11261
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 27255 times.
28416 if(g.objects[0].type == ssoNULL) continue;
11262
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 676 times.
1161 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11263 1161 ZCSubscreen& sub = vec.emplace_back();
11264 1161 sub.load_old(g);
11265 1161 }
11266
11267 222 return 0;
11268 222 }
11269
11270 28416 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11271 {
11272 28416 int32_t numsub=0;
11273 28416 byte temp_ss=0;
11274 subscreen_object temp_sub_stack;
11275 28416 subscreen_object *temp_sub = &temp_sub_stack;
11276
11277 char tempname[64];
11278
11279 // FWIW I never saw anything bigger than 20.
11280 #define MAX_DP1_LEN 1024
11281 char tempdp1[MAX_DP1_LEN];
11282
11283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(!pfread(tempname,64,f))
11284 {
11285 return qe_invalid;
11286 }
11287
11288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(s_version > 1)
11289 {
11290
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if(!p_getc(&temp_ss,f))
11291 {
11292 return qe_invalid;
11293 }
11294 28416 }
11295
11296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(s_version < 4)
11297 {
11298 uint8_t tmp=0;
11299
11300 if(!p_getc(&tmp,f))
11301 {
11302 return qe_invalid;
11303 }
11304
11305 numsub = (int32_t)tmp;
11306 }
11307 else
11308 {
11309 word tmp;
11310
11311
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if(!p_igetw(&tmp, f))
11312 {
11313 return qe_invalid;
11314 }
11315
11316 28416 numsub = (int32_t)tmp;
11317 }
11318
11319 int32_t j;
11320
11321
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75277 times.
✓ Branch 2 taken 46861 times.
✓ Branch 3 taken 28416 times.
75277 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11322 {
11323 46861 memset(temp_sub,0,sizeof(subscreen_object));
11324
11325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46861 times.
46861 switch(g->objects[j].type)
11326 {
11327 case ssoTEXT:
11328 case ssoTEXTBOX:
11329 case ssoCURRENTITEMTEXT:
11330 case ssoCURRENTITEMCLASSTEXT:
11331 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11332
11333 //fall through
11334 default:
11335 46861 memset(&g->objects[j],0,sizeof(subscreen_object));
11336 46861 break;
11337 }
11338
11339
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->type),f))
11340 return qe_invalid;
11341
11342
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->pos),f))
11343 return qe_invalid;
11344
11345
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(s_version < 5)
11346 {
11347 switch(temp_sub->pos)
11348 {
11349 case 0:
11350 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11351 break;
11352
11353 case 1:
11354 temp_sub->pos = sspUP;
11355 break;
11356
11357 case 2:
11358 temp_sub->pos = sspDOWN;
11359 break;
11360
11361 default:
11362 temp_sub->pos = 0;
11363 }
11364 }
11365
11366
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->x),f))
11367 return qe_invalid;
11368
11369
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->y),f))
11370 return qe_invalid;
11371
11372
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->w),f))
11373 return qe_invalid;
11374
11375
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->h),f))
11376 return qe_invalid;
11377
11378
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype1),f))
11379 return qe_invalid;
11380
11381
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color1),f))
11382 return qe_invalid;
11383
11384
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype2),f))
11385 return qe_invalid;
11386
11387
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color2),f))
11388 return qe_invalid;
11389
11390
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype3),f))
11391 return qe_invalid;
11392
11393
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color3),f))
11394 return qe_invalid;
11395
11396
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d1),f))
11397 return qe_invalid;
11398
11399
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d2),f))
11400 return qe_invalid;
11401
11402
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d3),f))
11403 return qe_invalid;
11404
11405
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d4),f))
11406 return qe_invalid;
11407
11408
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d5),f))
11409 return qe_invalid;
11410
11411
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d6),f))
11412 return qe_invalid;
11413
11414
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d7),f))
11415 return qe_invalid;
11416
11417
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d8),f))
11418 return qe_invalid;
11419
11420
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d9),f))
11421 return qe_invalid;
11422
11423
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d10),f))
11424 return qe_invalid;
11425
11426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46861 times.
46861 if(s_version < 2)
11427 {
11428 if(!p_igetl(&(temp_sub->speed),f))
11429 return qe_invalid;
11430
11431 if(!p_igetl(&(temp_sub->delay),f))
11432 return qe_invalid;
11433
11434 if(!p_igetl(&(temp_sub->frame),f))
11435 return qe_invalid;
11436 }
11437 else
11438 {
11439
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->speed),f))
11440 return qe_invalid;
11441
11442
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->delay),f))
11443 return qe_invalid;
11444
11445
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->frame),f))
11446 return qe_invalid;
11447 }
11448
11449 46861 int32_t temp_size=0;
11450
11451 // bool deletets = false;
11452
4/4
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 3482 times.
✓ Branch 2 taken 22301 times.
✓ Branch 3 taken 250 times.
46861 switch(temp_sub->type)
11453 {
11454 case ssoTEXT:
11455 case ssoTEXTBOX:
11456 case ssoCURRENTITEMTEXT:
11457 case ssoCURRENTITEMCLASSTEXT:
11458 {
11459 word temptempsize;
11460
11461
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if(!p_igetw(&temptempsize,f))
11462 {
11463 return qe_invalid;
11464 }
11465
11466 //temptempsize = temp1 + (temp2 << 8);
11467 3482 temp_size = (int32_t)temptempsize;
11468 3482 uint32_t char_length = temp_size+2;
11469
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if (char_length > MAX_DP1_LEN)
11470 {
11471 return qe_invalid;
11472 }
11473 3482 tempdp1[char_length - 1] = '\0';
11474
11475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3482 times.
3482 if(temp_size)
11476
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if(!pfread(tempdp1,temp_size+1,f))
11477 return qe_invalid;
11478 3482 break;
11479 }
11480
11481 case ssoLIFEMETER:
11482
1/2
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
250 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11483 temp_sub->d3 = 1;
11484
11485
1/2
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
250 if(!p_getc(&(temp_sub->dp1),f))
11486 return qe_invalid;
11487
11488 250 break;
11489
11490
11491 case ssoCURRENTITEM:
11492
11493
1/2
✓ Branch 0 taken 20828 times.
✗ Branch 1 not taken.
20828 if(s_version < 6)
11494 {
11495 switch(temp_sub->d1)
11496 {
11497 case ssiBOMB:
11498 temp_sub->d1 = itype_bomb;
11499 break;
11500
11501 case ssiSWORD:
11502 temp_sub->d1 = itype_sword;
11503 break;
11504
11505 case ssiSHIELD:
11506 temp_sub->d1 = itype_shield;
11507 break;
11508
11509 case ssiCANDLE:
11510 temp_sub->d1 = itype_candle;
11511 break;
11512
11513 case ssiLETTER:
11514 temp_sub->d1 = itype_letter;
11515 break;
11516
11517 case ssiPOTION:
11518 temp_sub->d1 = itype_potion;
11519 break;
11520
11521 case ssiLETTERPOTION:
11522 temp_sub->d1 = itype_letterpotion;
11523 break;
11524
11525 case ssiBOW:
11526 temp_sub->d1 = itype_bow;
11527 break;
11528
11529 case ssiARROW:
11530 temp_sub->d1 = itype_arrow;
11531 break;
11532
11533 case ssiBOWANDARROW:
11534 temp_sub->d1 = itype_bowandarrow;
11535 break;
11536
11537 case ssiBAIT:
11538 temp_sub->d1 = itype_bait;
11539 break;
11540
11541 case ssiRING:
11542 temp_sub->d1 = itype_ring;
11543 break;
11544
11545 case ssiBRACELET:
11546 temp_sub->d1 = itype_bracelet;
11547 break;
11548
11549 case ssiMAP:
11550 temp_sub->d1 = itype_map;
11551 break;
11552
11553 case ssiCOMPASS:
11554 temp_sub->d1 = itype_compass;
11555 break;
11556
11557 case ssiBOSSKEY:
11558 temp_sub->d1 = itype_bosskey;
11559 break;
11560
11561 case ssiMAGICKEY:
11562 temp_sub->d1 = itype_magickey;
11563 break;
11564
11565 case ssiBRANG:
11566 temp_sub->d1 = itype_brang;
11567 break;
11568
11569 case ssiWAND:
11570 temp_sub->d1 = itype_wand;
11571 break;
11572
11573 case ssiRAFT:
11574 temp_sub->d1 = itype_raft;
11575 break;
11576
11577 case ssiLADDER:
11578 temp_sub->d1 = itype_ladder;
11579 break;
11580
11581 case ssiWHISTLE:
11582 temp_sub->d1 = itype_whistle;
11583 break;
11584
11585 case ssiBOOK:
11586 temp_sub->d1 = itype_book;
11587 break;
11588
11589 case ssiWALLET:
11590 temp_sub->d1 = itype_wallet;
11591 break;
11592
11593 case ssiSBOMB:
11594 temp_sub->d1 = itype_sbomb;
11595 break;
11596
11597 case ssiHCPIECE:
11598 temp_sub->d1 = itype_heartpiece;
11599 break;
11600
11601 case ssiAMULET:
11602 temp_sub->d1 = itype_amulet;
11603 break;
11604
11605 case ssiFLIPPERS:
11606 temp_sub->d1 = itype_flippers;
11607 break;
11608
11609 case ssiHOOKSHOT:
11610 temp_sub->d1 = itype_hookshot;
11611 break;
11612
11613 case ssiLENS:
11614 temp_sub->d1 = itype_lens;
11615 break;
11616
11617 case ssiHAMMER:
11618 temp_sub->d1 = itype_hammer;
11619 break;
11620
11621 case ssiBOOTS:
11622 temp_sub->d1 = itype_boots;
11623 break;
11624
11625 case ssiDIVINEFIRE:
11626 temp_sub->d1 = itype_divinefire;
11627 break;
11628
11629 case ssiDIVINEESCAPE:
11630 temp_sub->d1 = itype_divineescape;
11631 break;
11632
11633 case ssiDIVINEPROTECTION:
11634 temp_sub->d1 = itype_divineprotection;
11635 break;
11636
11637 case ssiQUIVER:
11638 temp_sub->d1 = itype_quiver;
11639 break;
11640
11641 case ssiBOMBBAG:
11642 temp_sub->d1 = itype_bombbag;
11643 break;
11644
11645 case ssiCBYRNA:
11646 temp_sub->d1 = itype_cbyrna;
11647 break;
11648
11649 case ssiROCS:
11650 temp_sub->d1 = itype_rocs;
11651 break;
11652
11653 case ssiHOVERBOOTS:
11654 temp_sub->d1 = itype_hoverboots;
11655 break;
11656
11657 case ssiSPINSCROLL:
11658 temp_sub->d1 = itype_spinscroll;
11659 break;
11660
11661 case ssiCROSSSCROLL:
11662 temp_sub->d1 = itype_crossscroll;
11663 break;
11664
11665 case ssiQUAKESCROLL:
11666 temp_sub->d1 = itype_quakescroll;
11667 break;
11668
11669 case ssiWHISPRING:
11670 temp_sub->d1 = itype_whispring;
11671 break;
11672
11673 case ssiCHARGERING:
11674 temp_sub->d1 = itype_chargering;
11675 break;
11676
11677 case ssiPERILSCROLL:
11678 temp_sub->d1 = itype_perilscroll;
11679 break;
11680
11681 case ssiWEALTHMEDAL:
11682 temp_sub->d1 = itype_wealthmedal;
11683 break;
11684
11685 case ssiHEARTRING:
11686 temp_sub->d1 = itype_heartring;
11687 break;
11688
11689 case ssiMAGICRING:
11690 temp_sub->d1 = itype_magicring;
11691 break;
11692
11693 case ssiSPINSCROLL2:
11694 temp_sub->d1 = itype_spinscroll2;
11695 break;
11696
11697 case ssiQUAKESCROLL2:
11698 temp_sub->d1 = itype_quakescroll2;
11699 break;
11700
11701 case ssiAGONY:
11702 temp_sub->d1 = itype_agony;
11703 break;
11704
11705 case ssiSTOMPBOOTS:
11706 temp_sub->d1 = itype_stompboots;
11707 break;
11708
11709 case ssiWHIMSICALRING:
11710 temp_sub->d1 = itype_whimsicalring;
11711 break;
11712
11713 case ssiPERILRING:
11714 temp_sub->d1 = itype_perilring;
11715 break;
11716
11717 default:
11718 temp_sub->d1 += itype_custom1 - ssiMAX;
11719 }
11720 }
11721
11722 //fall-through
11723 default:
11724
1/2
✓ Branch 0 taken 43129 times.
✗ Branch 1 not taken.
43129 if(!p_getc(&(temp_sub->dp1),f))
11725 return qe_invalid;
11726
11727 43129 break;
11728 }
11729
11730
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 38167 times.
46861 if(s_version < 7)
11731 {
11732
3/3
✓ Branch 0 taken 32010 times.
✓ Branch 1 taken 1389 times.
✓ Branch 2 taken 4768 times.
38167 switch(temp_sub->type)
11733 {
11734 case ssoMAGICGAUGE:
11735 {
11736
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1248 times.
1389 if(!temp_sub->d9)
11737 1248 temp_sub->d9 = -1; //-1 now represents 'always'
11738 1389 break;
11739 }
11740 case ssoLIFEGAUGE:
11741 4768 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11742 4768 break;
11743 }
11744 38167 }
11745
11746
3/3
✓ Branch 0 taken 3482 times.
✓ Branch 1 taken 41785 times.
✓ Branch 2 taken 1594 times.
46861 switch(temp_sub->type)
11747 {
11748 case ssoTEXT:
11749 case ssoTEXTBOX:
11750 case ssoCURRENTITEMTEXT:
11751 case ssoCURRENTITEMCLASSTEXT:
11752
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3482 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11753
11754 3482 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11755 3482 g->objects[j].dp1 = new char[temp_size+2];
11756 3482 strcpy((char*)g->objects[j].dp1,tempdp1);
11757 3482 break;
11758
11759 case ssoCOUNTER:
11760
1/2
✓ Branch 0 taken 1594 times.
✗ Branch 1 not taken.
1594 if(s_version<3)
11761 {
11762 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11763 temp_sub->d8=0;
11764 }
11765
11766 default:
11767 43379 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11768 43379 break;
11769 }
11770
11771 46861 g->name[0] = '\0';
11772 46861 strncat(g->name, tempname, 64 - 1);
11773 46861 g->ss_type = temp_ss;
11774 46861 }
11775
11776
2/2
✓ Branch 0 taken 7227635 times.
✓ Branch 1 taken 28416 times.
7256051 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11777 {
11778 //clear all unused object in this subscreen -DD
11779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7227635 times.
7227635 switch(g->objects[j].type)
11780 {
11781 case ssoTEXT:
11782 case ssoTEXTBOX:
11783 case ssoCURRENTITEMTEXT:
11784 case ssoCURRENTITEMCLASSTEXT:
11785 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11786
11787 //fall through
11788 default:
11789 7227635 memset(&g->objects[j],0,sizeof(subscreen_object));
11790 7227635 break;
11791 }
11792 7227635 }
11793
11794 28416 return 0;
11795 28416 }
11796
11797 387 int32_t readsubscreens(PACKFILE *f)
11798 {
11799 word s_version;
11800 dword dummy;
11801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&s_version,f))
11802 return qe_invalid;
11803 387 FFCore.quest_format[vSubscreen] = s_version;
11804
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
11805 return qe_invalid;
11806
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy,f)) //section size
11807 return qe_invalid;
11808
11809
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 165 times.
387 if(s_version < 8)
11810 222 return read_old_subscreens(f,s_version);
11811
11812 165 subscreens_active.clear();
11813 165 subscreens_passive.clear();
11814 165 subscreens_overlay.clear();
11815
11816 byte sz;
11817
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&sz,f))
11818 return qe_invalid;
11819
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 165 times.
697 for(byte q = 0; q < sz; ++q)
11820 {
11821 532 ZCSubscreen& tmp = subscreens_active.emplace_back();
11822
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if (auto ret = tmp.read(f, s_version))
11823 return ret;
11824 532 }
11825
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&sz,f))
11826 return qe_invalid;
11827
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 165 times.
783 for(byte q = 0; q < sz; ++q)
11828 {
11829 618 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11830
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if (auto ret = tmp.read(f, s_version))
11831 return ret;
11832 618 }
11833
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&sz,f))
11834 return qe_invalid;
11835
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 165 times.
171 for(byte q = 0; q < sz; ++q)
11836 {
11837 6 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (auto ret = tmp.read(f, s_version))
11839 return ret;
11840 6 }
11841 165 return 0;
11842 387 }
11843
11844 void reset_subscreen(subscreen_group *tempss)
11845 {
11846 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11847 {
11848 switch(tempss->objects[i].type)
11849 {
11850 case ssoTEXT:
11851 case ssoTEXTBOX:
11852 case ssoCURRENTITEMTEXT:
11853 case ssoCURRENTITEMCLASSTEXT:
11854 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11855
11856 //fall through
11857 default:
11858 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11859 break;
11860 }
11861 }
11862 }
11863
11864 116 void reset_subscreens()
11865 {
11866 116 subscreens_active.clear();
11867 116 subscreens_passive.clear();
11868 116 subscreens_overlay.clear();
11869 116 }
11870
11871 116 int32_t setupsubscreens()
11872 {
11873 116 reset_subscreens();
11874 //return 0;
11875
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 232 times.
348 for(int q = 0; q < 2; ++q)
11876 {
11877 232 subscreens_active.emplace_back();
11878 232 subscreens_passive.emplace_back();
11879 232 }
11880 116 int32_t tempsubscreen=subscr_mode;
11881
11882
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(tempsubscreen>=ssdtMAX)
11883 tempsubscreen=0;
11884
11885
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
116 switch(tempsubscreen)
11886 {
11887 case ssdtOLD:
11888 case ssdtNEWSUBSCR:
11889 case ssdtREV2:
11890 case ssdtBSZELDA:
11891 case ssdtBSZELDAMODIFIED:
11892 case ssdtBSZELDAENHANCED:
11893 case ssdtBSZELDACOMPLETE:
11894 {
11895 116 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11896 116 subscreens_active[0].sub_type=sstACTIVE;
11897 116 subscreens_active[0].name = "Active Subscreen (Triforce)";
11898 116 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11899 116 subscreens_active[1].sub_type=sstACTIVE;
11900 116 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11901 116 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11902 116 subscreens_passive[0].sub_type=sstPASSIVE;
11903 116 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11904 116 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11905 116 subscreens_passive[1].sub_type=sstPASSIVE;
11906 116 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11907 116 break;
11908 }
11909
11910 case ssdtZ3:
11911 {
11912 subscreens_active[0].load_old(z3_active_a);
11913 subscreens_active[0].sub_type=sstACTIVE;
11914 subscreens_active[1].load_old(z3_active_ab);
11915 subscreens_active[1].sub_type=sstACTIVE;
11916 subscreens_passive[0].load_old(z3_passive_a);
11917 subscreens_passive[0].sub_type=sstPASSIVE;
11918 subscreens_passive[1].load_old(z3_passive_ab);
11919 subscreens_passive[1].sub_type=sstPASSIVE;
11920 break;
11921 }
11922 }
11923 116 subscr_mode = ssdtMAX;
11924 116 return 0;
11925 }
11926
11927 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
11928
11929 extern script_data *ffscripts[NUMSCRIPTFFC];
11930 extern script_data *itemscripts[NUMSCRIPTITEM];
11931 extern script_data *guyscripts[NUMSCRIPTGUYS];
11932 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11933 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11934 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11935 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11936 extern script_data *playerscripts[NUMSCRIPTHERO];
11937 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11938 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11939 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11940 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11941 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11942
11943 static std::vector<const script_data*> read_scripts;
11944
11945 416 static script_data fake_script_data(ScriptType::None, 0);
11946
11947 463 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11948 {
11949 int32_t dummy;
11950 463 word s_version=0, zmeta_version=0;
11951 463 byte numscripts=0;
11952 463 numscripts=numscripts; //to avoid unused variables warnings
11953 int32_t ret;
11954 463 read_scripts.clear();
11955 463 zasm_scripts.clear();
11956
11957 //section version info
11958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 463 times.
463 if(!p_igetw(&s_version,f))
11959 {
11960 return qe_invalid;
11961 }
11962
11963 463 FFCore.quest_format[vFFScript] = s_version;
11964
11965
1/2
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
463 if(!read_deprecated_section_cversion(f))
11966 {
11967 return qe_invalid;
11968 }
11969
11970
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 182 times.
463 if(s_version >= 18)
11971 {
11972
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetw(&zmeta_version,f))
11973 {
11974 return qe_invalid;
11975 }
11976 182 }
11977
11978 //section size
11979
1/2
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
463 if(!p_igetl(&dummy,f))
11980 {
11981 return qe_invalid;
11982 }
11983
11984
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 224 times.
463 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
11985 463 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
11986
11987
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 116 times.
463 if(s_version >= 27)
11988 {
11989 116 ret = read_quest_zasm(f, s_version);
11990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(ret)
11991 return qe_invalid;
11992 116 }
11993
11994 //finally... section data
11995
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 417 times.
198561 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
11996 {
11997 198144 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
11998
11999
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if (ret)
12000 {
12001 return qe_invalid;
12002 }
12003 198144 }
12004
12005 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12006 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12007 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12008 * there was a version bump a week before a change that broke stuff.
12009 */
12010
7/8
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 235 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
✓ Branch 4 taken 182 times.
✓ Branch 5 taken 182 times.
✓ Branch 6 taken 182 times.
✓ Branch 7 taken 182 times.
417 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12011 {
12012 599 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12013 599 }
12014
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if(s_version < 19)
12015 {
12016 205 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12017 205 }
12018
12019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(s_version > 1)
12020 {
12021
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12022 {
12023 99072 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12024
12025
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if (ret)
12026 {
12027 return qe_invalid;
12028 }
12029 99072 }
12030
12031
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12032 {
12033 99072 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12034
12035
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if (ret)
12036 {
12037 return qe_invalid;
12038 }
12039 99072 }
12040
12041
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12042 {
12043 99072 ret = read_one_ffscript(f, Header, i, s_version, &fake_script_data, zmeta_version);
12044
12045
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if (ret)
12046 {
12047 return qe_invalid;
12048 }
12049 99072 }
12050
12051
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12052 {
12053 99072 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12054
12055
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if (ret)
12056 {
12057 return qe_invalid;
12058 }
12059 99072 }
12060
12061
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if(s_version > 16)
12062 {
12063
2/2
✓ Branch 0 taken 1456 times.
✓ Branch 1 taken 182 times.
1638 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12064 {
12065 1456 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12066
12067
1/2
✓ Branch 0 taken 1456 times.
✗ Branch 1 not taken.
1456 if (ret)
12068 {
12069 return qe_invalid;
12070 }
12071 1456 }
12072 182 }
12073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 else if(s_version > 13)
12074 {
12075 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12076 {
12077 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12078
12079 if (ret)
12080 {
12081 return qe_invalid;
12082 }
12083 }
12084
12085 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12086 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12087
12088 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12089 }
12090
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 else if(s_version > 4)
12091 {
12092
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12093 {
12094 820 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12095
12096
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if (ret)
12097 {
12098 return qe_invalid;
12099 }
12100 820 }
12101
12102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12103
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12104
12105
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12106
12107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12108
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12109
12110
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12111
12112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12113
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_F6];
12114
12115
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12116
12117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12118
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12119
12120
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12121 205 }
12122 else
12123 {
12124 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12125 {
12126 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12127
12128 if (ret)
12129 {
12130 return qe_invalid;
12131 }
12132 }
12133
12134 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12135 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12136
12137 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12138
12139 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12140 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12141
12142 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12143
12144 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12145 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12146
12147 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12148
12149 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12150 delete globalscripts[GLOBAL_SCRIPT_F6];
12151
12152 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12153
12154 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12155 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12156
12157 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12158 }
12159
12160
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if(s_version > 10) //expanded the number of Hero scripts to 5.
12161 {
12162
2/2
✓ Branch 0 taken 910 times.
✓ Branch 1 taken 182 times.
1092 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12163 {
12164 910 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12165
12166
1/2
✓ Branch 0 taken 910 times.
✗ Branch 1 not taken.
910 if (ret)
12167 {
12168 return qe_invalid;
12169 }
12170 910 }
12171 182 }
12172 else
12173 {
12174
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 205 times.
820 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12175 {
12176 615 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12177
12178
1/2
✓ Branch 0 taken 615 times.
✗ Branch 1 not taken.
615 if (ret)
12179 {
12180 return qe_invalid;
12181 }
12182 615 }
12183
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(playerscripts[3] != NULL)
12184
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete playerscripts[3];
12185
12186
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12187
12188
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(playerscripts[4] != NULL)
12189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 delete playerscripts[4];
12190
12191
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12192 }
12193
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
387 if(s_version > 8 && s_version < 10)
12194 {
12195
12196 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12197 {
12198 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12199
12200 if (ret)
12201 {
12202 return qe_invalid;
12203 }
12204 }
12205 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12206 {
12207 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12208
12209 if (ret)
12210 {
12211 return qe_invalid;
12212 }
12213 }
12214
12215 }
12216
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version >= 10)
12217 {
12218
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12219 {
12220 46592 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12221
12222
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if (ret)
12223 {
12224 return qe_invalid;
12225 }
12226 46592 }
12227
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12228 {
12229 46592 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12230
12231
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if (ret)
12232 {
12233 return qe_invalid;
12234 }
12235 46592 }
12236
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12237 {
12238 46592 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12239
12240
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if (ret)
12241 {
12242 return qe_invalid;
12243 }
12244 46592 }
12245
12246 182 }
12247
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version >=12)
12248 {
12249
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12250 {
12251 46592 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12252
12253
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if (ret)
12254 {
12255 return qe_invalid;
12256 }
12257 46592 }
12258 182 }
12259
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version >=15)
12260 {
12261
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 182 times.
93366 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12262 {
12263 93184 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12264
12265
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if (ret)
12266 {
12267 return qe_invalid;
12268 }
12269 93184 }
12270 182 }
12271
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version >19)
12272 {
12273 182 word numgenscripts = NUMSCRIPTSGENERIC;
12274
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetw(&numgenscripts,f))
12275 {
12276 return qe_invalid;
12277 }
12278
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 182 times.
93366 for(int32_t i = 0; i < numgenscripts; i++)
12279 {
12280 93184 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12281
12282
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if (ret)
12283 {
12284 return qe_invalid;
12285 }
12286 93184 }
12287 182 }
12288
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 165 times.
387 if(s_version >21)
12289 {
12290 165 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12291
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_igetw(&numsubscripts,f))
12292 {
12293 return qe_invalid;
12294 }
12295
2/2
✓ Branch 0 taken 42240 times.
✓ Branch 1 taken 165 times.
42405 for(int32_t i = 0; i < numsubscripts; i++)
12296 {
12297 42240 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12298
12299
1/2
✓ Branch 0 taken 42240 times.
✗ Branch 1 not taken.
42240 if (ret)
12300 {
12301 return qe_invalid;
12302 }
12303 42240 }
12304 165 }
12305 387 }
12306
12307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(s_version > 2)
12308 {
12309 int32_t bufsize;
12310 387 p_igetl(&bufsize, f);
12311
2/4
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
387 if (bufsize < 0 || bufsize > 1024*1024*10)
12312 {
12313 // God help anyone storing more than 10MB of code in the script buffer.
12314 return qe_invalid;
12315 }
12316 387 char * buf = new char[bufsize+1];
12317 387 pfread(buf, bufsize, f);
12318 387 buf[bufsize]=0;
12319
12320
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 zScript = string(buf);
12321
12322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 delete[] buf;
12323 word numffcbindings;
12324 387 p_igetw(&numffcbindings, f);
12325
12326
2/2
✓ Branch 0 taken 10354 times.
✓ Branch 1 taken 387 times.
10741 for(int32_t i=0; i<numffcbindings; i++)
12327 {
12328 word id;
12329 10354 p_igetw(&id, f);
12330 10354 p_igetl(&bufsize, f);
12331
2/4
✓ Branch 0 taken 10354 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10354 times.
10354 if (bufsize < 0 || bufsize > 1024)
12332 return qe_invalid;
12333 10354 buf = new char[bufsize+1];
12334 10354 pfread(buf, bufsize, f);
12335 10354 buf[bufsize]=0;
12336
12337 //fix for buggy older saved quests -DD
12338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10354 times.
10354 if(id < NUMSCRIPTFFC-1)
12339 10354 ffcmap[id].scriptname = buf;
12340
12341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10354 times.
10354 delete[] buf;
12342 10354 }
12343
12344 word numglobalbindings;
12345 387 p_igetw(&numglobalbindings, f);
12346
12347
2/2
✓ Branch 0 taken 1578 times.
✓ Branch 1 taken 387 times.
1965 for(int32_t i=0; i<numglobalbindings; i++)
12348 {
12349 word id;
12350 1578 p_igetw(&id, f);
12351 1578 p_igetl(&bufsize, f);
12352
2/4
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1578 times.
✗ Branch 3 not taken.
1578 if (bufsize < 0 || bufsize > 1024)
12353 return qe_invalid;
12354 1578 buf = new char[bufsize+1];
12355 1578 pfread(buf, bufsize, f);
12356 1578 buf[bufsize]=0;
12357
12358 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12359 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12360 // Ignore these. -DD
12361
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 1020 times.
1578 if (id < NUMSCRIPTGLOBAL)
12362 {
12363 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12364
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(strcmp(buf,"~Continue") == 0)
12365 {
12366 globalmap[id].scriptname = "";
12367
12368 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12369 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12370 }
12371 else
12372 {
12373 1020 globalmap[id].scriptname = buf;
12374 }
12375 1020 }
12376
12377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1578 times.
1578 delete[] buf;
12378 1578 }
12379
12380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(s_version > 3)
12381 {
12382 word numitembindings;
12383 387 p_igetw(&numitembindings, f);
12384
12385
2/2
✓ Branch 0 taken 1299 times.
✓ Branch 1 taken 387 times.
1686 for(int32_t i=0; i<numitembindings; i++)
12386 {
12387 word id;
12388 1299 p_igetw(&id, f);
12389 1299 p_igetl(&bufsize, f);
12390
2/4
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1299 times.
1299 if (bufsize < 0 || bufsize > 1024)
12391 return qe_invalid;
12392 1299 buf = new char[bufsize+1];
12393 1299 pfread(buf, bufsize, f);
12394 1299 buf[bufsize]=0;
12395
12396 //fix this too
12397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1299 times.
1299 if(id <NUMSCRIPTITEM-1)
12398 1299 itemmap[id].scriptname = buf;
12399
12400
1/2
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
1299 delete[] buf;
12401 1299 }
12402 387 }
12403 //(v9+)
12404
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version > 8)
12405 {
12406 //npc scripts
12407 word numnpcbindings;
12408 182 p_igetw(&numnpcbindings, f);
12409
12410
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 182 times.
214 for(int32_t i=0; i<numnpcbindings; i++)
12411 {
12412 word id;
12413 32 p_igetw(&id, f);
12414 32 p_igetl(&bufsize, f);
12415
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if (bufsize < 0 || bufsize > 1024)
12416 return qe_invalid;
12417 32 buf = new char[bufsize+1];
12418 32 pfread(buf, bufsize, f);
12419 32 buf[bufsize]=0;
12420
12421 //fix this too
12422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(id <NUMSCRIPTGUYS-1)
12423 32 npcmap[id].scriptname = buf;
12424
12425
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 delete[] buf;
12426 32 }
12427 //lweapon
12428 word numlwpnbindings;
12429 182 p_igetw(&numlwpnbindings, f);
12430
12431
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 182 times.
506 for(int32_t i=0; i<numlwpnbindings; i++)
12432 {
12433 word id;
12434 324 p_igetw(&id, f);
12435 324 p_igetl(&bufsize, f);
12436
2/4
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 324 times.
324 if (bufsize < 0 || bufsize > 1024)
12437 return qe_invalid;
12438 324 buf = new char[bufsize+1];
12439 324 pfread(buf, bufsize, f);
12440 324 buf[bufsize]=0;
12441
12442 //fix this too
12443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 324 times.
324 if(id <NUMSCRIPTWEAPONS-1)
12444 324 lwpnmap[id].scriptname = buf;
12445
12446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 324 times.
324 delete[] buf;
12447 324 }
12448 //eweapon
12449 word numewpnbindings;
12450 182 p_igetw(&numewpnbindings, f);
12451
12452
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 182 times.
479 for(int32_t i=0; i<numewpnbindings; i++)
12453 {
12454 word id;
12455 297 p_igetw(&id, f);
12456 297 p_igetl(&bufsize, f);
12457
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if (bufsize < 0 || bufsize > 1024)
12458 return qe_invalid;
12459 297 buf = new char[bufsize+1];
12460 297 pfread(buf, bufsize, f);
12461 297 buf[bufsize]=0;
12462
12463 //fix this too
12464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(id <NUMSCRIPTWEAPONS-1)
12465 297 ewpnmap[id].scriptname = buf;
12466
12467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 delete[] buf;
12468 297 }
12469 //hero
12470 word numherobindings;
12471 182 p_igetw(&numherobindings, f);
12472
12473
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 182 times.
205 for(int32_t i=0; i<numherobindings; i++)
12474 {
12475 word id;
12476 23 p_igetw(&id, f);
12477 23 p_igetl(&bufsize, f);
12478
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if (bufsize < 0 || bufsize > 1024)
12479 return qe_invalid;
12480 23 buf = new char[bufsize+1];
12481 23 pfread(buf, bufsize, f);
12482 23 buf[bufsize]=0;
12483
12484 //fix this too
12485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTHERO-1)
12486 23 playermap[id].scriptname = buf;
12487
12488
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12489 23 }
12490 //dmaps
12491 word numdmapbindings;
12492 182 p_igetw(&numdmapbindings, f);
12493
12494
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 182 times.
596 for(int32_t i=0; i<numdmapbindings; i++)
12495 {
12496 word id;
12497 414 p_igetw(&id, f);
12498 414 p_igetl(&bufsize, f);
12499
2/4
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 414 times.
414 if (bufsize < 0 || bufsize > 1024)
12500 return qe_invalid;
12501 414 buf = new char[bufsize+1];
12502 414 pfread(buf, bufsize, f);
12503 414 buf[bufsize]=0;
12504
12505 //fix this too
12506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 414 times.
414 if(id <NUMSCRIPTSDMAP-1)
12507 414 dmapmap[id].scriptname = buf;
12508
12509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 414 times.
414 delete[] buf;
12510 414 }
12511 //screen
12512 word numscreenbindings;
12513 182 p_igetw(&numscreenbindings, f);
12514
12515
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 182 times.
588 for(int32_t i=0; i<numscreenbindings; i++)
12516 {
12517 word id;
12518 406 p_igetw(&id, f);
12519 406 p_igetl(&bufsize, f);
12520
2/4
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 406 times.
✗ Branch 3 not taken.
406 if (bufsize < 0 || bufsize > 1024)
12521 return qe_invalid;
12522 406 buf = new char[bufsize+1];
12523 406 pfread(buf, bufsize, f);
12524 406 buf[bufsize]=0;
12525
12526 //fix this too
12527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(id <NUMSCRIPTSDMAP-1)
12528 406 screenmap[id].scriptname = buf;
12529
12530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 delete[] buf;
12531 406 }
12532 182 }
12533
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version > 11)
12534 {
12535 word numspritebindings;
12536 182 p_igetw(&numspritebindings, f);
12537
12538
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 182 times.
231 for(int32_t i=0; i<numspritebindings; i++)
12539 {
12540 word id;
12541 49 p_igetw(&id, f);
12542 49 p_igetl(&bufsize, f);
12543
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
49 if (bufsize < 0 || bufsize > 1024)
12544 return qe_invalid;
12545 49 buf = new char[bufsize+1];
12546 49 pfread(buf, bufsize, f);
12547 49 buf[bufsize]=0;
12548
12549 //fix this too
12550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(id <NUMSCRIPTSDMAP-1)
12551 49 itemspritemap[id].scriptname = buf;
12552
12553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 delete[] buf;
12554 49 }
12555 182 }
12556
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version >= 15)
12557 {
12558 word numcombobindings;
12559 182 p_igetw(&numcombobindings, f);
12560
12561
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 182 times.
339 for(int32_t i=0; i<numcombobindings; i++)
12562 {
12563 word id;
12564 157 p_igetw(&id, f);
12565 157 p_igetl(&bufsize, f);
12566
2/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
157 if (bufsize < 0 || bufsize > 1024)
12567 return qe_invalid;
12568 157 buf = new char[bufsize+1];
12569 157 pfread(buf, bufsize, f);
12570 157 buf[bufsize]=0;
12571
12572 //fix this too
12573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 if(id <NUMSCRIPTSCOMBODATA-1)
12574 157 comboscriptmap[id].scriptname = buf;
12575
12576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 delete[] buf;
12577 157 }
12578 182 }
12579
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version > 19)
12580 {
12581 word numgenericbindings;
12582 182 p_igetw(&numgenericbindings, f);
12583
12584
2/2
✓ Branch 0 taken 1543 times.
✓ Branch 1 taken 182 times.
1725 for(int32_t i=0; i<numgenericbindings; i++)
12585 {
12586 word id;
12587 1543 p_igetw(&id, f);
12588 1543 p_igetl(&bufsize, f);
12589
2/4
✓ Branch 0 taken 1543 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1543 times.
✗ Branch 3 not taken.
1543 if (bufsize < 0 || bufsize > 1024)
12590 return qe_invalid;
12591 1543 buf = new char[bufsize+1];
12592 1543 pfread(buf, bufsize, f);
12593 1543 buf[bufsize]=0;
12594
12595 //fix this too
12596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1543 times.
1543 if(id <NUMSCRIPTSGENERIC-1)
12597 1543 genericmap[id].scriptname = buf;
12598
12599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1543 times.
1543 delete[] buf;
12600 1543 }
12601 182 }
12602
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 165 times.
387 if(s_version > 21)
12603 {
12604 word numsubscreenbindings;
12605 165 p_igetw(&numsubscreenbindings, f);
12606
12607
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 165 times.
173 for(int32_t i=0; i<numsubscreenbindings; i++)
12608 {
12609 word id;
12610 8 p_igetw(&id, f);
12611 8 p_igetl(&bufsize, f);
12612
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (bufsize < 0 || bufsize > 1024)
12613 return qe_invalid;
12614 8 buf = new char[bufsize+1];
12615 8 pfread(buf, bufsize, f);
12616 8 buf[bufsize]=0;
12617
12618 //fix this too
12619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(id <NUMSCRIPTSSUBSCREEN-1)
12620 8 subscreenmap[id].scriptname = buf;
12621
12622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 delete[] buf;
12623 8 }
12624 165 }
12625 387 }
12626
12627 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12628 // This is only updated when the scripts have been recompiled.
12629 // They should all match each other.
12630 387 std::optional<word> zscript_version;
12631
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if (s_version >= 16)
12632 {
12633
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 6357 times.
6537 for (auto script : read_scripts)
12634 {
12635
2/2
✓ Branch 0 taken 6355 times.
✓ Branch 1 taken 2 times.
6357 if (script->meta.ffscript_v == 0)
12636 {
12637 // These scripts were saved in a version prior to this field being set.
12638 // See https://discord.com/channels/876899628556091432/1368485306394738718
12639 2 zscript_version = 16;
12640 2 break;
12641 }
12642
1/2
✓ Branch 0 taken 6355 times.
✗ Branch 1 not taken.
6355 if (script->meta.ffscript_v > s_version)
12643 break;
12644
12645
2/2
✓ Branch 0 taken 6192 times.
✓ Branch 1 taken 163 times.
6355 if (!zscript_version.has_value())
12646 {
12647 163 zscript_version = script->meta.ffscript_v;
12648 163 continue;
12649 }
12650
12651
1/2
✓ Branch 0 taken 6192 times.
✗ Branch 1 not taken.
6192 if (zscript_version.value() != script->meta.ffscript_v)
12652 {
12653 zscript_version.reset();
12654 break;
12655 }
12656 }
12657
12658
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 17 times.
182 if (!zscript_version.has_value())
12659 17 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12660 182 }
12661 387 setZScriptVersion(zscript_version.value_or(s_version));
12662 387 read_scripts.clear();
12663
12664 387 return 0;
12665 387 }
12666
12667 void(*reset_scripts_hook)();
12668
12669 469 void reset_scripts()
12670 {
12671 // We can't modify the script data while jit threads are possibly compiling them.
12672
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 458 times.
469 if (reset_scripts_hook)
12673 458 reset_scripts_hook();
12674
12675
2/2
✓ Branch 0 taken 240128 times.
✓ Branch 1 taken 469 times.
240597 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12676 {
12677
1/2
✓ Branch 0 taken 240128 times.
✗ Branch 1 not taken.
240128 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12678 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12679 240128 }
12680
12681
2/2
✓ Branch 0 taken 240128 times.
✓ Branch 1 taken 469 times.
240597 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12682 {
12683
1/2
✓ Branch 0 taken 240128 times.
✗ Branch 1 not taken.
240128 if (ffscripts[i])
12684 240128 ffscripts[i]->disable();
12685 else
12686 ffscripts[i] = new script_data(ScriptType::FFC, i);
12687 240128 }
12688
12689
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12690 {
12691
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (itemscripts[i])
12692 120064 itemscripts[i]->disable();
12693 else
12694 itemscripts[i] = new script_data(ScriptType::Item, i);
12695 120064 }
12696
12697
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12698 {
12699
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (guyscripts[i])
12700 120064 guyscripts[i]->disable();
12701 else
12702 guyscripts[i] = new script_data(ScriptType::NPC, i);
12703 120064 }
12704
12705
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12706 {
12707
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (screenscripts[i])
12708 120064 screenscripts[i]->disable();
12709 else
12710 screenscripts[i] = new script_data(ScriptType::Screen, i);
12711 120064 }
12712
12713
2/2
✓ Branch 0 taken 3752 times.
✓ Branch 1 taken 469 times.
4221 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12714 {
12715
1/2
✓ Branch 0 taken 3752 times.
✗ Branch 1 not taken.
3752 if (globalscripts[i])
12716 3752 globalscripts[i]->disable();
12717 else
12718 globalscripts[i] = new script_data(ScriptType::Global, i);
12719 3752 }
12720
12721
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 469 times.
2814 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
12722 {
12723
1/2
✓ Branch 0 taken 2345 times.
✗ Branch 1 not taken.
2345 if (playerscripts[i])
12724 2345 playerscripts[i]->disable();
12725 else
12726 playerscripts[i] = new script_data(ScriptType::Hero, i);
12727 2345 }
12728
12729
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12730 {
12731
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (lwpnscripts[i])
12732 120064 lwpnscripts[i]->disable();
12733 else
12734 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12735 120064 }
12736
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12737 {
12738
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (ewpnscripts[i])
12739 120064 ewpnscripts[i]->disable();
12740 else
12741 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12742 120064 }
12743
12744
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12745 {
12746
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (dmapscripts[i])
12747 120064 dmapscripts[i]->disable();
12748 else
12749 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12750 120064 }
12751
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12752 {
12753
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (itemspritescripts[i])
12754 120064 itemspritescripts[i]->disable();
12755 else
12756 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12757 120064 }
12758
2/2
✓ Branch 0 taken 240128 times.
✓ Branch 1 taken 469 times.
240597 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12759 {
12760
1/2
✓ Branch 0 taken 240128 times.
✗ Branch 1 not taken.
240128 if (comboscripts[i])
12761 240128 comboscripts[i]->disable();
12762 else
12763 comboscripts[i] = new script_data(ScriptType::Combo, i);
12764 240128 }
12765
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 120064 times.
120533 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12766 {
12767
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (subscreenscripts[i])
12768 120064 subscreenscripts[i]->disable();
12769 else
12770 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12771 120064 }
12772 469 }
12773
12774 // 3.0+ calls this.
12775 116 int32_t read_quest_zasm(PACKFILE *f, word s_version)
12776 {
12777 int32_t num_commands;
12778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_igetl(&num_commands,f))
12779 return qe_invalid;
12780 #ifdef ZC_FUZZ
12781 const int32_t command_limit = 300000;
12782 #else
12783 116 const int32_t command_limit = 25000000;
12784 #endif
12785
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
116 if (num_commands < 0 || num_commands > command_limit)
12786 return qe_invalid;
12787
12788 116 std::vector<ffscript> zasm;
12789
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 zasm.reserve(num_commands);
12790
2/2
✓ Branch 0 taken 2919590 times.
✓ Branch 1 taken 116 times.
2919706 for(int32_t j=0; j<num_commands; j++)
12791 {
12792
1/2
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
2919590 ffscript temp_script;
12793
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetw(&(temp_script.command),f))
12794 return qe_invalid;
12795
12796
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetl(&(temp_script.arg1),f))
12797 return qe_invalid;
12798
12799
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetl(&(temp_script.arg2),f))
12800 return qe_invalid;
12801
12802
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetl(&(temp_script.arg3),f))
12803 return qe_invalid;
12804
12805 2919590 uint32_t sz = 0;
12806
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetl(&sz,f))
12807 return qe_invalid;
12808
2/2
✓ Branch 0 taken 28939 times.
✓ Branch 1 taken 2890651 times.
2919590 if(sz) //string found
12809 {
12810
1/2
✓ Branch 0 taken 28939 times.
✗ Branch 1 not taken.
28939 temp_script.strptr = new std::string();
12811 char dummy;
12812
2/2
✓ Branch 0 taken 494335 times.
✓ Branch 1 taken 28939 times.
523274 for(size_t q = 0; q < sz; ++q)
12813 {
12814
2/4
✓ Branch 0 taken 494335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 494335 times.
✗ Branch 3 not taken.
494335 if(!p_getc(&dummy,f))
12815 return qe_invalid;
12816
1/2
✓ Branch 0 taken 494335 times.
✗ Branch 1 not taken.
494335 temp_script.strptr->push_back(dummy);
12817 494335 }
12818 28939 }
12819
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetl(&sz,f))
12820 return qe_invalid;
12821
2/2
✓ Branch 0 taken 3459 times.
✓ Branch 1 taken 2916131 times.
2919590 if(sz) //vector found
12822 {
12823
1/2
✓ Branch 0 taken 3459 times.
✗ Branch 1 not taken.
3459 temp_script.vecptr = new std::vector<int32_t>();
12824 int32_t dummy;
12825
2/2
✓ Branch 0 taken 11560 times.
✓ Branch 1 taken 3459 times.
15019 for(size_t q = 0; q < sz; ++q)
12826 {
12827
2/4
✓ Branch 0 taken 11560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11560 times.
✗ Branch 3 not taken.
11560 if(!p_igetl(&dummy,f))
12828 return qe_invalid;
12829
1/2
✓ Branch 0 taken 11560 times.
✗ Branch 1 not taken.
11560 temp_script.vecptr->push_back(dummy);
12830 11560 }
12831 3459 }
12832
1/2
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
2919590 zasm.emplace_back(std::move(temp_script));
12833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2919590 times.
2919590 }
12834
12835
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 assert(zasm_scripts.empty());
12836 116 zasm_script_id id = zasm_scripts.size();
12837
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
116 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
12838
12839 116 return 0;
12840 116 }
12841
12842 1013209 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12843 {
12844 ASSERT(script);
12845
2/2
✓ Branch 0 taken 566261 times.
✓ Branch 1 taken 446948 times.
1013209 if(s_version < 27)
12846 566261 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
12847
12848 char exists;
12849
1/2
✓ Branch 0 taken 446948 times.
✗ Branch 1 not taken.
446948 if (!p_getc(&exists, f))
12850 return qe_invalid;
12851
2/2
✓ Branch 0 taken 3313 times.
✓ Branch 1 taken 443635 times.
446948 if (!exists)
12852 {
12853 443635 script->disable();
12854 443635 return 0;
12855 }
12856
12857 //Read meta
12858 {
12859 3313 zasm_meta temp_meta;
12860
12861
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.zasm_v),f))
12862 return qe_invalid;
12863
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.meta_v),f))
12864 return qe_invalid;
12865
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.ffscript_v),f))
12866 return qe_invalid;
12867
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_getc(&(temp_meta.script_type),f))
12868 return qe_invalid;
12869
12870
2/2
✓ Branch 0 taken 26504 times.
✓ Branch 1 taken 3313 times.
29817 for(int32_t q = 0; q < 8; ++q)
12871 {
12872
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getcstr(&temp_meta.run_idens[q],f))
12873 return qe_invalid;
12874 26504 }
12875
12876
2/2
✓ Branch 0 taken 3313 times.
✓ Branch 1 taken 26504 times.
29817 for(int32_t q = 0; q < 8; ++q)
12877
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getc(&(temp_meta.run_types[q]),f))
12878 return qe_invalid;
12879
12880
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_getc(&(temp_meta.flags),f))
12881 return qe_invalid;
12882
12883
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.compiler_v1),f))
12884 return qe_invalid;
12885
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.compiler_v2),f))
12886 return qe_invalid;
12887
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.compiler_v3),f))
12888 return qe_invalid;
12889
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.compiler_v4),f))
12890 return qe_invalid;
12891
12892
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_getcstr(&temp_meta.script_name,f))
12893 return qe_invalid;
12894
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_getcstr(&temp_meta.author,f))
12895 return qe_invalid;
12896 3313 auto num_meta_attrib = 10;
12897
2/2
✓ Branch 0 taken 33130 times.
✓ Branch 1 taken 3313 times.
36443 for(auto q = 0; q < num_meta_attrib; ++q)
12898 {
12899
2/4
✓ Branch 0 taken 33130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33130 times.
✗ Branch 3 not taken.
33130 if(!p_getcstr(&temp_meta.attributes[q],f))
12900 return qe_invalid;
12901
2/4
✓ Branch 0 taken 33130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33130 times.
✗ Branch 3 not taken.
33130 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12902 return qe_invalid;
12903 33130 }
12904
2/2
✓ Branch 0 taken 26504 times.
✓ Branch 1 taken 3313 times.
29817 for(auto q = 0; q < 8; ++q)
12905 {
12906
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getcstr(&temp_meta.attribytes[q],f))
12907 return qe_invalid;
12908
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12909 return qe_invalid;
12910 26504 }
12911
2/2
✓ Branch 0 taken 26504 times.
✓ Branch 1 taken 3313 times.
29817 for(auto q = 0; q < 8; ++q)
12912 {
12913
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12914 return qe_invalid;
12915
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12916 return qe_invalid;
12917 26504 }
12918
2/2
✓ Branch 0 taken 53008 times.
✓ Branch 1 taken 3313 times.
56321 for(auto q = 0; q < 16; ++q)
12919 {
12920
2/4
✓ Branch 0 taken 53008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53008 times.
✗ Branch 3 not taken.
53008 if(!p_getcstr(&temp_meta.usrflags[q],f))
12921 return qe_invalid;
12922
2/4
✓ Branch 0 taken 53008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53008 times.
✗ Branch 3 not taken.
53008 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12923 return qe_invalid;
12924 53008 }
12925
2/2
✓ Branch 0 taken 26504 times.
✓ Branch 1 taken 3313 times.
29817 for(auto q = 0; q < 8; ++q)
12926 {
12927
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getcstr(&temp_meta.initd[q],f))
12928 return qe_invalid;
12929
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getwstr(&temp_meta.initd_help[q],f))
12930 return qe_invalid;
12931 26504 }
12932
2/2
✓ Branch 0 taken 3313 times.
✓ Branch 1 taken 26504 times.
29817 for(auto q = 0; q < 8; ++q)
12933 {
12934
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getc(&temp_meta.initd_type[q],f))
12935 return qe_invalid;
12936 26504 }
12937
12938
1/2
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
3313 script->meta = temp_meta;
12939
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
3313 }
12940
1/2
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
3313 if(!p_igetl(&script->pc, f))
12941 return qe_invalid;
12942
1/2
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
3313 if(!p_igetl(&script->end_pc, f))
12943 return qe_invalid;
12944
12945
1/2
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
3313 if (script == &fake_script_data)
12946 return 0;
12947
12948
1/2
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
3313 assert(zasm_scripts.size() == 1);
12949 3313 auto& zs = zasm_scripts[0];
12950 3313 script->zasm_script = zs;
12951
12952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3313 times.
3313 if (script->valid())
12953 {
12954 3313 zs->script_datas.push_back(script);
12955 3313 read_scripts.push_back(script);
12956 3313 }
12957
12958 3313 return 0;
12959 1013209 }
12960
12961 566261 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12962 {
12963 566261 char b33[34] = {0};
12964 566261 b33[33] = 0;
12965 566261 int32_t num_commands=1000;
12966
12967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 566261 times.
566261 if(s_version>=2)
12968 {
12969
1/2
✓ Branch 0 taken 566261 times.
✗ Branch 1 not taken.
566261 if(!p_igetl(&num_commands,f))
12970 {
12971 return qe_invalid;
12972 }
12973 566261 }
12974
12975 #ifdef ZC_FUZZ
12976 const int32_t command_limit = 300000;
12977 #else
12978 566261 const int32_t command_limit = 10000000;
12979 #endif
12980
2/4
✓ Branch 0 taken 566261 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 566261 times.
566261 if (num_commands < 0 || num_commands > command_limit)
12981 {
12982 return qe_invalid;
12983 }
12984
12985 566261 std::vector<ffscript> zasm;
12986
1/2
✓ Branch 0 taken 566261 times.
✗ Branch 1 not taken.
566261 zasm.reserve(num_commands);
12987
12988
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 316315 times.
566261 if(s_version >= 16)
12989 {
12990
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 zasm_meta temp_meta;
12991
12992
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.zasm_v),f))
12993 {
12994 return qe_invalid;
12995 }
12996
12997
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.meta_v),f))
12998 {
12999 return qe_invalid;
13000 }
13001
13002
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.ffscript_v),f))
13003 {
13004 return qe_invalid;
13005 }
13006
13007
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.script_type),f))
13008 {
13009 return qe_invalid;
13010 }
13011
13012
2/2
✓ Branch 0 taken 1999568 times.
✓ Branch 1 taken 249946 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13013 {
13014
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1855688 times.
1999568 if(zmeta_version < 3)
13015 {
13016
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13017 {
13018
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13019 {
13020 return qe_invalid;
13021 }
13022 4748040 }
13023
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
13024 143880 }
13025 else
13026 {
13027
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.run_idens[q],f))
13028 {
13029 return qe_invalid;
13030 }
13031 }
13032 1999568 }
13033
13034
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 1999568 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13035 {
13036
2/4
✓ Branch 0 taken 1999568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1999568 times.
✗ Branch 3 not taken.
1999568 if(!p_getc(&(temp_meta.run_types[q]),f))
13037 {
13038 return qe_invalid;
13039 }
13040 1999568 }
13041
13042
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.flags),f))
13043 {
13044 return qe_invalid;
13045 }
13046
13047
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v1),f))
13048 {
13049 return qe_invalid;
13050 }
13051
13052
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v2),f))
13053 {
13054 return qe_invalid;
13055 }
13056
13057
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v3),f))
13058 {
13059 return qe_invalid;
13060 }
13061
13062
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v4),f))
13063 {
13064 return qe_invalid;
13065 }
13066
13067
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 231961 times.
249946 if(zmeta_version == 2)
13068 {
13069
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13070 {
13071
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13072 {
13073 return qe_invalid;
13074 }
13075 593505 }
13076
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
13077
13078
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13079 {
13080
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13081 {
13082 return qe_invalid;
13083 }
13084 593505 }
13085
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
13086 17985 }
13087
1/2
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
231961 else if(zmeta_version > 2)
13088 {
13089
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.script_name,f))
13090 return qe_invalid;
13091
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.author,f))
13092 return qe_invalid;
13093 231961 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13094
2/2
✓ Branch 0 taken 2319610 times.
✓ Branch 1 taken 231961 times.
2551571 for(auto q = 0; q < num_meta_attrib; ++q)
13095 {
13096
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getcstr(&temp_meta.attributes[q],f))
13097 return qe_invalid;
13098
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13099 return qe_invalid;
13100 2319610 }
13101
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13102 {
13103
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attribytes[q],f))
13104 return qe_invalid;
13105
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13106 return qe_invalid;
13107 1855688 }
13108
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13109 {
13110
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13111 return qe_invalid;
13112
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13113 return qe_invalid;
13114 1855688 }
13115
2/2
✓ Branch 0 taken 3711376 times.
✓ Branch 1 taken 231961 times.
3943337 for(auto q = 0; q < 16; ++q)
13116 {
13117
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getcstr(&temp_meta.usrflags[q],f))
13118 return qe_invalid;
13119
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13120 return qe_invalid;
13121 3711376 }
13122 231961 }
13123
2/2
✓ Branch 0 taken 231961 times.
✓ Branch 1 taken 17985 times.
249946 if(zmeta_version > 3)
13124 {
13125
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13126 {
13127
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.initd[q],f))
13128 return qe_invalid;
13129
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.initd_help[q],f))
13130 return qe_invalid;
13131 1855688 }
13132
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13133 {
13134
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getc(&temp_meta.initd_type[q],f))
13135 return qe_invalid;
13136 1855688 }
13137 231961 }
13138 else
13139 {
13140
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13141 {
13142
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13143 143880 }
13144 }
13145
13146
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 script->meta = temp_meta;
13147
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 249946 times.
✓ Branch 2 taken 316315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 316315 times.
✗ Branch 5 not taken.
566261 } else script->meta = {};
13148
13149
2/2
✓ Branch 0 taken 74674 times.
✓ Branch 1 taken 107364918 times.
107439592 for(int32_t j=0; j<num_commands; j++)
13150 {
13151
1/2
✓ Branch 0 taken 107364918 times.
✗ Branch 1 not taken.
107364918 auto& sc = zasm.emplace_back();
13152
2/4
✓ Branch 0 taken 107364918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107364918 times.
✗ Branch 3 not taken.
107364918 if(!p_igetw(&sc.command,f))
13153 {
13154 return qe_invalid;
13155 }
13156
13157
2/2
✓ Branch 0 taken 106873331 times.
✓ Branch 1 taken 491587 times.
107364918 if(sc.command == 0xFFFF)
13158 491587 break;
13159 else
13160 {
13161
2/4
✓ Branch 0 taken 106873331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106873331 times.
✗ Branch 3 not taken.
106873331 if(!p_igetl(&sc.arg1,f))
13162 {
13163 return qe_invalid;
13164 }
13165
13166
2/4
✓ Branch 0 taken 106873331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106873331 times.
✗ Branch 3 not taken.
106873331 if(!p_igetl(&sc.arg2,f))
13167 {
13168 return qe_invalid;
13169 }
13170
13171
2/2
✓ Branch 0 taken 1047747 times.
✓ Branch 1 taken 105825584 times.
106873331 if(s_version >= 24)
13172
2/4
✓ Branch 0 taken 1047747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047747 times.
✗ Branch 3 not taken.
1047747 if(!p_igetl(&sc.arg3,f))
13173 return qe_invalid;
13174
13175
2/2
✓ Branch 0 taken 8222037 times.
✓ Branch 1 taken 98651294 times.
106873331 if(s_version >= 21)
13176 {
13177 8222037 uint32_t sz = 0;
13178
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13179 {
13180 return qe_invalid;
13181 }
13182
2/2
✓ Branch 0 taken 19400 times.
✓ Branch 1 taken 8202637 times.
8222037 if(sz) //string found
13183 {
13184
1/2
✓ Branch 0 taken 19400 times.
✗ Branch 1 not taken.
19400 sc.strptr = new std::string();
13185 char dummy;
13186
2/2
✓ Branch 0 taken 1165008 times.
✓ Branch 1 taken 19400 times.
1184408 for(size_t q = 0; q < sz; ++q)
13187 {
13188
2/4
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165008 times.
✗ Branch 3 not taken.
1165008 if(!p_getc(&dummy,f))
13189 {
13190 return qe_invalid;
13191 }
13192
1/2
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
1165008 sc.strptr->push_back(dummy);
13193 1165008 }
13194 19400 }
13195
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13196 {
13197 return qe_invalid;
13198 }
13199
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8221104 times.
8222037 if(sz) //vector found
13200 {
13201
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13202 int32_t dummy;
13203
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13204 {
13205
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13206 {
13207 return qe_invalid;
13208 }
13209
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13210 11526 }
13211 933 }
13212 8222037 }
13213 }
13214 106873331 }
13215
13216
2/2
✓ Branch 0 taken 496885 times.
✓ Branch 1 taken 69376 times.
566261 if (script == &fake_script_data)
13217 69376 return 0;
13218
13219 // If the first command is unknown, invalidate the whole thing.
13220 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13221
5/6
✓ Branch 0 taken 427587 times.
✓ Branch 1 taken 69298 times.
✓ Branch 2 taken 415407 times.
✓ Branch 3 taken 12180 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 415407 times.
496885 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13222 {
13223 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13224 zasm.clear();
13225 }
13226
13227 496885 zasm_script_id id = zasm_scripts.size();
13228
3/6
✓ Branch 0 taken 496885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 496885 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 496885 times.
✗ Branch 5 not taken.
496885 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13229 496885 script->zasm_script = zs;
13230 496885 script->pc = 0;
13231 496885 script->end_pc = zs->size;
13232
3/4
✓ Branch 0 taken 496885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12180 times.
✓ Branch 3 taken 484705 times.
496885 if (script->valid())
13233 {
13234
1/2
✓ Branch 0 taken 12180 times.
✗ Branch 1 not taken.
12180 zs->script_datas.push_back(script);
13235
1/2
✓ Branch 0 taken 12180 times.
✗ Branch 1 not taken.
12180 read_scripts.push_back(script);
13236 12180 }
13237
13238 496885 return 0;
13239 566261 }
13240
13241 extern SAMPLE customsfxdata[WAV_COUNT];
13242 extern uint8_t customsfxflag[WAV_COUNT>>3];
13243 extern int32_t sfxdat;
13244 extern DATAFILE *sfxdata;
13245 const char *old_sfx_string[Z35] =
13246 {
13247 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13248 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13249 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13250 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13251 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13252 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13253 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13254 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13255 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13256 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13257 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13258 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13259 };
13260 char *sfx_string[WAV_COUNT];
13261
13262 387 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13263 {
13264 //these are here to bypass compiler warnings about unused arguments
13265 387 Header=Header;
13266
13267 int32_t dummy;
13268 387 word s_version=0;
13269 //int32_t ret;
13270 387 SAMPLE temp_sample = {};
13271 387 temp_sample.loop_start=0;
13272 387 temp_sample.loop_end=0;
13273 387 temp_sample.param=0;
13274
13275 //section version info
13276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&s_version,f))
13277 {
13278 return qe_invalid;
13279 }
13280
13281 387 FFCore.quest_format[vSFX] = s_version;
13282
13283
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
13284 {
13285 return qe_invalid;
13286 }
13287
13288 //section size
13289
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy,f))
13290 {
13291 return qe_invalid;
13292 }
13293
13294 /* HIGHLY UNORTHODOX UPDATING THING, by L
13295 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13296 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13297 * changing from 1 to 2.
13298 */
13299
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version < 2)
13300 set_qr(qr_GOTOLESSNOTEQUAL,1);
13301
13302 /* End highly unorthodox updating thing */
13303
13304 387 int32_t wavcount = WAV_COUNT;
13305
13306
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version < 6)
13307 wavcount = 128;
13308
13309 uint8_t tempflag[WAV_COUNT>>3];
13310
13311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(s_version < 4)
13312 {
13313 memset(tempflag, 0xFF, WAV_COUNT>>3);
13314 }
13315 else
13316 {
13317
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version < 6)
13318 memset(tempflag, 0, WAV_COUNT>>3);
13319
13320
2/2
✓ Branch 0 taken 12384 times.
✓ Branch 1 taken 387 times.
12771 for(int32_t i=0; i<(wavcount>>3); i++)
13321 {
13322 12384 p_getc(&tempflag[i], f);
13323 12384 }
13324
13325 }
13326
13327
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version>4)
13328 {
13329
2/2
✓ Branch 0 taken 98685 times.
✓ Branch 1 taken 387 times.
99072 for(int32_t i=1; i<WAV_COUNT; i++)
13330 {
13331 98685 sprintf(sfx_string[i],"s%03d",i);
13332
13333
2/2
✓ Branch 0 taken 75465 times.
✓ Branch 1 taken 23220 times.
98685 if((i<Z35))
13334 23220 strcpy(sfx_string[i], old_sfx_string[i-1]);
13335
13336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98685 times.
98685 if(i>=wavcount)
13337 continue;
13338
2/2
✓ Branch 0 taken 19851 times.
✓ Branch 1 taken 78834 times.
98685 if(get_bit(tempflag, i-1))
13339 {
13340 char tempname[36];
13341
13342
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!pfread(tempname, 36, f))
13343 {
13344 return qe_invalid;
13345 }
13346
13347 19851 sfx_string[i][0] = '\0';
13348 19851 strncat(sfx_string[i], tempname, 36 - 1);
13349 19851 }
13350 else
13351 {
13352 78834 sprintf(sfx_string[i],"s%03d",i);
13353
13354
2/2
✓ Branch 0 taken 68932 times.
✓ Branch 1 taken 9902 times.
78834 if(i<Z35)
13355 9902 strcpy(sfx_string[i], old_sfx_string[i-1]);
13356 78834 sfx_string[i][35] = 0; //Force NULL Termination
13357 }
13358 98685 }
13359 387 }
13360 else
13361 {
13362 for(int32_t i=1; i<WAV_COUNT; i++)
13363 {
13364 sprintf(sfx_string[i],"s%03d",i);
13365
13366 if(i<Z35)
13367 strcpy(sfx_string[i], old_sfx_string[i-1]);
13368 }
13369 }
13370
13371 //finally... section data
13372
2/2
✓ Branch 0 taken 98685 times.
✓ Branch 1 taken 387 times.
99072 for(int32_t i=1; i<wavcount; i++)
13373 {
13374
2/2
✓ Branch 0 taken 19851 times.
✓ Branch 1 taken 78834 times.
98685 if(get_bit(tempflag, i-1))
13375 {
13376
13377
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&dummy,f))
13378 {
13379 return qe_invalid;
13380 }
13381
13382 19851 (temp_sample.bits) = dummy;
13383
13384
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&dummy,f))
13385 {
13386 return qe_invalid;
13387 }
13388
13389 19851 (temp_sample.stereo) = dummy;
13390
13391
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&dummy,f))
13392 {
13393 return qe_invalid;
13394 }
13395
13396 19851 (temp_sample.freq) = dummy;
13397
13398
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&dummy,f))
13399 {
13400 return qe_invalid;
13401 }
13402
13403 19851 (temp_sample.priority) = dummy;
13404
13405
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&(temp_sample.len),f))
13406 {
13407 return qe_invalid;
13408 }
13409
13410
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&(temp_sample.loop_start),f))
13411 {
13412 return qe_invalid;
13413 }
13414
13415
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&(temp_sample.loop_end),f))
13416 {
13417 return qe_invalid;
13418 }
13419
13420
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&(temp_sample.param),f))
13421 {
13422 return qe_invalid;
13423 }
13424
13425 19851 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13426 #ifdef ZC_FUZZ
13427 const int32_t sfx_limit = 100000;
13428 if (len < 0 || len > sfx_limit)
13429 {
13430 return qe_invalid;
13431 }
13432 #endif
13433 19851 temp_sample.data = calloc(len,1);
13434
13435
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(s_version < 3)
13436 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13437
13438 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19851 times.
19851 if(s_version < 2)
13440 {
13441 if(!pfread(temp_sample.data, len,f))
13442 {
13443 return qe_invalid;
13444 }
13445 }
13446 else
13447 {
13448 //re-endianfy the data
13449 19851 int32_t wordstoread = len / sizeof(word);
13450
13451
2/2
✓ Branch 0 taken 551768152 times.
✓ Branch 1 taken 19851 times.
551788003 for(int32_t j=0; j<wordstoread; j++)
13452 {
13453 word temp;
13454
13455
1/2
✓ Branch 0 taken 551768152 times.
✗ Branch 1 not taken.
551768152 if(!p_igetw(&temp, f))
13456 {
13457 return qe_invalid;
13458 }
13459
13460 551768152 ((word *)temp_sample.data)[j] = temp;
13461 551768152 }
13462 }
13463 19851 }
13464
2/2
✓ Branch 0 taken 9902 times.
✓ Branch 1 taken 68932 times.
78834 else if(i < Z35)
13465 {
13466 9902 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13467 9902 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13468 9902 set_bit(tempflag, i-1, 1);
13469 9902 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13470 9902 temp_sample.data = calloc(len,1);
13471 9902 memcpy(temp_sample.data, datsamp->data, len);
13472 9902 }
13473 68932 else continue;
13474
13475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29753 times.
29753 if(customsfxdata[i].data!=NULL)
13476 {
13477 // delete [] customsfxdata[i].data;
13478 29753 free(customsfxdata[i].data);
13479 29753 }
13480
13481 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13482 29753 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13483 29753 customsfxdata[i].data = calloc(len2,1);
13484 29753 customsfxdata[i].bits = temp_sample.bits;
13485 29753 customsfxdata[i].stereo = temp_sample.stereo;
13486 29753 customsfxdata[i].freq = temp_sample.freq;
13487 29753 customsfxdata[i].priority = temp_sample.priority;
13488 29753 customsfxdata[i].len = temp_sample.len;
13489 29753 customsfxdata[i].loop_start = temp_sample.loop_start;
13490 29753 customsfxdata[i].loop_end = temp_sample.loop_end;
13491 29753 customsfxdata[i].param = temp_sample.param;
13492 29753 int32_t cpylen = len2;
13493
13494
1/2
✓ Branch 0 taken 29753 times.
✗ Branch 1 not taken.
29753 if(s_version<3)
13495 {
13496 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13497 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13498 }
13499
13500 29753 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13501
13502 29753 free(temp_sample.data);
13503 29753 }
13504
13505 387 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13506
13507 387 sfxdat=0;
13508 387 return 0;
13509 387 }
13510
13511 469 void setupsfx()
13512 {
13513
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=1; i<WAV_COUNT; i++)
13514 {
13515 119595 sprintf(sfx_string[i],"s%03d",i);
13516
13517
2/2
✓ Branch 0 taken 91455 times.
✓ Branch 1 taken 28140 times.
119595 if(i<Z35)
13518 {
13519 28140 strcpy(sfx_string[i], old_sfx_string[i-1]);
13520 28140 }
13521
13522 119595 memset(customsfxflag, 0, WAV_COUNT>>3);
13523
13524 119595 int32_t j=i;
13525
13526
2/2
✓ Branch 0 taken 28609 times.
✓ Branch 1 taken 90986 times.
119595 if(i>Z35)
13527 {
13528 90986 i=Z35;
13529 90986 }
13530
13531 119595 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13532
13533
2/2
✓ Branch 0 taken 92565 times.
✓ Branch 1 taken 27030 times.
119595 if(customsfxdata[j].data!=NULL)
13534 {
13535 // delete [] customsfxdata[j].data;
13536 27030 free(customsfxdata[j].data);
13537 27030 }
13538
13539 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13540 119595 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13541 119595 customsfxdata[j].bits = temp_sample->bits;
13542 119595 customsfxdata[j].stereo = temp_sample->stereo;
13543 119595 customsfxdata[j].freq = temp_sample->freq;
13544 119595 customsfxdata[j].priority = temp_sample->priority;
13545 119595 customsfxdata[j].len = temp_sample->len;
13546 119595 customsfxdata[j].loop_start = temp_sample->loop_start;
13547 119595 customsfxdata[j].loop_end = temp_sample->loop_end;
13548 119595 customsfxdata[j].param = temp_sample->param;
13549 119595 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13550 119595 i=j;
13551 119595 }
13552 469 }
13553
13554 extern char *guy_string[eMAXGUYS];
13555 extern const char *old_guy_string[OLDMAXGUYS];
13556
13557 469 int32_t readguys(PACKFILE *f, zquestheader *Header)
13558 {
13559
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
469 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (should_skip) return 0;
13561
13562 dword dummy;
13563 word guy_cversion;
13564 469 word guyversion=0;
13565
13566
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 446 times.
469 if(Header->zelda_version >= 0x193)
13567 {
13568 //section version info
13569
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&guyversion,f))
13570 {
13571 return qe_invalid;
13572 }
13573
13574 446 FFCore.quest_format[vGuys] = guyversion;
13575
13576 // Note: this is the only instance where "cversion" is ever used.
13577
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&guy_cversion,f))
13578 {
13579 return qe_invalid;
13580 }
13581
13582 //section size
13583
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy,f))
13584 {
13585 return qe_invalid;
13586 }
13587 446 }
13588
13589
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
469 if(guyversion > 3)
13590 {
13591
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 387 times.
198531 for(int32_t i=0; i<MAXGUYS; i++)
13592 {
13593 char tempname[64];
13594
13595 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13596 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13597
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198144 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13598 {
13599 memset(tempname, 0, sizeof(char)*64);
13600 sprintf(tempname, "e%03d", i);
13601 strcpy(guy_string[i], tempname);
13602
13603 continue;
13604 }
13605
13606
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!pfread(tempname, 64, f))
13607 {
13608 return qe_invalid;
13609 }
13610
13611 // Don't retain names of uneditable enemy entries!
13612 // for version upgrade to 2.5
13613
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198144 if(guyversion < 23 && i >= 177)
13614 {
13615 // some of the older builds have names such as 'zz123',
13616 // (this order gets messed up with some eXXX and some zzXXX)
13617 // so let's update to the newer naming convection. -Gleeok
13618 char tmpbuf[64];
13619 memset(tmpbuf, 0, sizeof(char)*64);
13620 sprintf(tmpbuf, "zz%03d", i);
13621
13622 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13623 {
13624 memset(tempname, 0, sizeof(char)*64);
13625 sprintf(tempname, "e%03d", i);
13626 }
13627 }
13628
13629
6/6
✓ Branch 0 taken 68499 times.
✓ Branch 1 taken 129645 times.
✓ Branch 2 taken 65016 times.
✓ Branch 3 taken 3483 times.
✓ Branch 4 taken 56346 times.
✓ Branch 5 taken 8670 times.
198144 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13630 {
13631 189474 guy_string[i][0] = '\0';
13632 189474 strncat(guy_string[i], tempname, 64 - 1);
13633 189474 }
13634 else
13635 {
13636 8670 strcpy(guy_string[i],old_guy_string[i]);
13637 }
13638 198144 }
13639 387 }
13640 else
13641 {
13642
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13643 {
13644 41984 sprintf(guy_string[i],"zz%03d",i);
13645 41984 }
13646
13647
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13648 {
13649 14514 strcpy(guy_string[i],old_guy_string[i]);
13650 14514 }
13651 }
13652
13653
13654 //finally... section data
13655 469 init_guys(guyversion); //using default data for now...
13656
13657 // Goriya guy fix
13658
3/6
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
469 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13659 {
13660
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13661 {
13662 60 guysbuf[gGORIYA].tile=130;
13663 60 guysbuf[gGORIYA].e_tile=130;
13664 60 }
13665 82 }
13666
13667
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
469 if(Header->zelda_version < 0x193)
13668 {
13669
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13670 {
13671 5 guysbuf[eDODONGO].cset=14;
13672 5 guysbuf[eDODONGO].bosspal=spDIG;
13673 5 }
13674 23 }
13675 // Not sure when this first changed, but it's necessary for 2.10, at least
13676 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13677 //2.10 Fixes
13678
3/6
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
469 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13679 {
13680 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13681 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13682 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13683 82 guysbuf[eCENT1].attributes[2] = 1;
13684 82 guysbuf[eCENT2].attributes[2] = 1;
13685 82 }
13686
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
469 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13687 {
13688 469 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13689 469 }
13690
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
469 if(Header->zelda_version <= 0x210)
13691 {
13692 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13693 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13694 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13695 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13696
13697 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13698 82 guysbuf[eBATROBE].attributes[3] = 1;
13699 //guysbuf[eSUMMONER].misc4 = 1;
13700 82 guysbuf[eWWIZ].attributes[3] = 1;
13701 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13702 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13703 82 }
13704
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 12 times.
469 if(Header->zelda_version == 0x190)
13705 {
13706 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13707 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13708 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13709 12 }
13710
13711 // The versions here may not be correct
13712 // zelda_version>=0x211 handled at guyversion<24
13713
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 451 times.
469 if(Header->zelda_version <= 0x190)
13714 {
13715 18 guysbuf[eCENT1].attributes[2] = 0;
13716 18 guysbuf[eCENT2].attributes[2] = 0;
13717 18 guysbuf[eMOLDORM].attributes[1] = 0;
13718 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13719 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13720 18 }
13721
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 64 times.
451 else if(Header->zelda_version <= 0x210)
13722 {
13723 64 guysbuf[eCENT1].attributes[2] = 1;
13724 64 guysbuf[eCENT2].attributes[2] = 1;
13725 64 guysbuf[eMOLDORM].attributes[1] = 0;
13726 64 }
13727
13728
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
469 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13729 {
13730 82 guysbuf[eKEESE1].attributes[15] = 120;
13731 82 guysbuf[eKEESE2].attributes[15] = 120;
13732 82 guysbuf[eKEESE3].attributes[15] = 120;
13733 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13734 82 guysbuf[eKEESE1].attributes[16] = 16;
13735 82 guysbuf[eKEESE2].attributes[16] = 16;
13736 82 guysbuf[eKEESE3].attributes[16] = 16;
13737 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13738
13739 82 guysbuf[ePEAHAT].attributes[15] = 80;
13740 82 guysbuf[ePEAHAT].attributes[16] = 16;
13741
13742 82 guysbuf[eGHINI2].attributes[15] = 120;
13743 82 guysbuf[eGHINI2].attributes[16] = 10;
13744
13745
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13746 {
13747 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13748 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13749 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13750 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13751 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13752 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13753 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13754 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13755 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13756 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13757 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13758 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13759 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13760 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13761 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13762 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13763 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13764 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13765 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13766 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13767 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13768 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13769 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13770 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13771 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13772 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13773 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13774 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13775 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13776 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13777 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13778 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13779 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13780 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13781 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13782 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13783 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13784 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13785 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13786 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13787 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13788 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13789 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13790 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13791 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13792 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13793 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13794 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13795 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13796 66 }
13797 82 }
13798
13799
13800
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(guyversion<=2)
13801 {
13802 82 return readherosprites2(f, guyversion==2?0:-1);
13803 }
13804
13805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(guyversion > 3)
13806 {
13807 guydata tempguy;
13808
13809
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 387 times.
198531 for(int32_t i=0; i<MAXGUYS; i++)
13810 {
13811
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 23) // May 2012 : 512 max enemies
13812 {
13813 if(i >= OLDBETAMAXGUYS)
13814 {
13815 memset(&guysbuf[i], 0, sizeof(guydata));
13816 continue;
13817 }
13818 }
13819
13820 198144 memset(&tempguy, 0, sizeof(guydata));
13821
13822 uint32_t flags1;
13823 uint32_t flags2;
13824
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetl(&(flags1),f))
13825 {
13826 return qe_invalid;
13827 }
13828
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetl(&(flags2),f))
13829 {
13830 return qe_invalid;
13831 }
13832 198144 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
13833
13834
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion >= 36 ) //expanded tiles
13835 {
13836
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.tile),f))
13837 {
13838 return qe_invalid;
13839 }
13840 93184 }
13841 else
13842 {
13843
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.tile),f))
13844 {
13845 return qe_invalid;
13846 }
13847 }
13848
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.width),f))
13849 {
13850 return qe_invalid;
13851 }
13852
13853
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.height),f))
13854 {
13855 return qe_invalid;
13856 }
13857
13858
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion >= 36 ) //expanded tiles
13859 {
13860
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.s_tile),f))
13861 {
13862 return qe_invalid;
13863 }
13864 93184 }
13865 else
13866 {
13867
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.s_tile),f))
13868 {
13869 return qe_invalid;
13870 }
13871 }
13872
13873
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.s_width),f))
13874 {
13875 return qe_invalid;
13876 }
13877
13878
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.s_height),f))
13879 {
13880 return qe_invalid;
13881 }
13882
13883
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion >= 36 ) //expanded tiles
13884 {
13885
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.e_tile),f))
13886 {
13887 return qe_invalid;
13888 }
13889 93184 }
13890 else
13891 {
13892
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.e_tile),f))
13893 {
13894 return qe_invalid;
13895 }
13896 }
13897
13898
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.e_width),f))
13899 {
13900 return qe_invalid;
13901 }
13902
13903
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.e_height),f))
13904 {
13905 return qe_invalid;
13906 }
13907
13908
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.hp),f))
13909 {
13910 return qe_invalid;
13911 }
13912
13913
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.family),f))
13914 {
13915 return qe_invalid;
13916 }
13917
13918
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
198144 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13919 {
13920 if(get_qr(qr_NEWENEMYTILES))
13921 {
13922 tempguy.s_tile=tempguy.e_tile+120;
13923 tempguy.s_width=tempguy.e_width;
13924 tempguy.s_height=tempguy.e_height;
13925 }
13926 else tempguy.s_tile=860;
13927 }
13928
13929
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.cset),f))
13930 {
13931 return qe_invalid;
13932 }
13933
13934
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.anim),f))
13935 {
13936 return qe_invalid;
13937 }
13938
13939
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.e_anim),f))
13940 {
13941 return qe_invalid;
13942 }
13943
13944
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.frate),f))
13945 {
13946 return qe_invalid;
13947 }
13948
13949
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.e_frate),f))
13950 {
13951 return qe_invalid;
13952 }
13953
13954
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 13) // April 2009
13955 {
13956 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13957 {
13958 tempguy.frate *= 2;
13959 tempguy.e_frate *= 2;
13960 }
13961 }
13962
13963
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 14) // May 1 2009
13964 {
13965 if(tempguy.anim==a2FRMSLOW)
13966 {
13967 tempguy.anim=a2FRM;
13968 tempguy.frate *= 2;
13969 }
13970
13971 if(tempguy.e_anim==a2FRMSLOW)
13972 {
13973 tempguy.e_anim=a2FRM;
13974 tempguy.e_frate *= 2;
13975 }
13976
13977 if(tempguy.anim==aFLIPSLOW)
13978 {
13979 tempguy.anim=aFLIP;
13980 tempguy.frate *= 2;
13981 }
13982
13983 if(tempguy.e_anim==aFLIPSLOW)
13984 {
13985 tempguy.e_anim=aFLIP;
13986 tempguy.e_frate *= 2;
13987 }
13988
13989 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
13990
13991 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
13992
13993 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
13994 {
13995 tempguy.anim=a4FRM4DIR;
13996 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13997 }
13998
13999 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14000 {
14001 tempguy.e_anim=a4FRM4DIR;
14002 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14003 }
14004 }
14005
14006
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.dp),f))
14007 {
14008 return qe_invalid;
14009 }
14010
14011 //correction for guy fire
14012
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 6)
14013 {
14014 if(i == gFIRE)
14015 tempguy.dp = 2;
14016 }
14017
14018
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.wdp),f))
14019 {
14020 return qe_invalid;
14021 }
14022
14023
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.weapon),f))
14024 {
14025 return qe_invalid;
14026 }
14027
14028 //correction for bosses using triple, "rising" fireballs
14029
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 5)
14030 {
14031 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14032 i == eGOHMA3 || i == eGOHMA4)
14033 {
14034 if(tempguy.weapon == ewFireball)
14035 tempguy.weapon = ewFireball2;
14036 }
14037 }
14038
14039
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.rate),f))
14040 {
14041 return qe_invalid;
14042 }
14043
14044
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.hrate),f))
14045 {
14046 return qe_invalid;
14047 }
14048
14049
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.step),f))
14050 {
14051 return qe_invalid;
14052 }
14053
14054 // HIGHLY UNORTHODOX UPDATING THING, part 2
14055
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198144 if(fixpolsvoice && tempguy.family==eePOLSV)
14056 {
14057 tempguy.step /= 2;
14058 }
14059
14060
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.homing),f))
14061 {
14062 return qe_invalid;
14063 }
14064
14065
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.grumble),f))
14066 {
14067 return qe_invalid;
14068 }
14069
14070
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.item_set),f))
14071 {
14072 return qe_invalid;
14073 }
14074
14075
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14076 {
14077
2/2
✓ Branch 0 taken 1981440 times.
✓ Branch 1 taken 198144 times.
2179584 for (int q = 0; q < 10; ++q)
14078 {
14079
1/2
✓ Branch 0 taken 1981440 times.
✗ Branch 1 not taken.
1981440 if (!p_igetl(&(tempguy.attributes[q]), f))
14080 {
14081 return qe_invalid;
14082 }
14083 1981440 }
14084 198144 }
14085 else
14086 {
14087 int16_t tempMisc;
14088
14089 for(int q=0;q<10;q++)
14090 {
14091 if (!p_igetw(&tempMisc, f))
14092 {
14093 return qe_invalid;
14094 }
14095 tempguy.attributes[q] = tempMisc;
14096 }
14097
14098 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14099 {
14100 if(tempguy.family == eeWIZZ && !(tempguy.attributes[0]))
14101 tempguy.attributes[4] = 74;
14102 }
14103
14104 }
14105
14106
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.bgsfx),f))
14107 {
14108 return qe_invalid;
14109 }
14110
14111
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.bosspal),f))
14112 {
14113 return qe_invalid;
14114 }
14115
14116
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.extend),f))
14117 {
14118 return qe_invalid;
14119 }
14120
14121 //! Enemy Defences
14122
14123 //If a 2.50 quest, use only the 2.5 defences.
14124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
198144 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14125 {
14126
2/2
✓ Branch 0 taken 3764736 times.
✓ Branch 1 taken 198144 times.
3962880 for(int32_t j=0; j<edefLAST; j++)
14127 {
14128
1/2
✓ Branch 0 taken 3764736 times.
✗ Branch 1 not taken.
3764736 if(!p_getc(&(tempguy.defense[j]),f))
14129 {
14130 return qe_invalid;
14131 }
14132 3764736 }
14133 //then copy the generic script defence to all the new script defences
14134
14135 198144 }
14136
14137
14138
14139
14140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
198144 if(guyversion >= 18)
14141 {
14142
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.hitsfx),f))
14143 {
14144 return qe_invalid;
14145 }
14146
14147
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.deadsfx),f))
14148 {
14149 return qe_invalid;
14150 }
14151 198144 }
14152
14153
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion >= 22)
14154 {
14155
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetl(&(tempguy.attributes[10]), f))
14156 {
14157 return qe_invalid;
14158 }
14159
14160
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetl(&(tempguy.attributes[11]),f))
14161 {
14162 return qe_invalid;
14163 }
14164 198144 }
14165 else if(guyversion >= 19)
14166 {
14167 int16_t tempMisc;
14168
14169 if(!p_igetw(&tempMisc,f))
14170 {
14171 return qe_invalid;
14172 }
14173
14174 tempguy.attributes[10] = tempMisc;
14175
14176 if(!p_igetw(&tempMisc,f))
14177 {
14178 return qe_invalid;
14179 }
14180
14181 tempguy.attributes[11] = tempMisc;
14182 }
14183
14184 //If a 2.54 or later quest, use all of the defences.
14185
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion > 24) // Add new guyversion conditional statement
14186 {
14187
2/2
✓ Branch 0 taken 2050048 times.
✓ Branch 1 taken 93184 times.
2143232 for(int32_t j=edefLAST; j<edefLAST255; j++)
14188 {
14189
1/2
✓ Branch 0 taken 2050048 times.
✗ Branch 1 not taken.
2050048 if(!p_getc(&(tempguy.defense[j]),f))
14190 {
14191 return qe_invalid;
14192 }
14193 2050048 }
14194 93184 }
14195
14196
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14197 {
14198
2/2
✓ Branch 0 taken 1049600 times.
✓ Branch 1 taken 104960 times.
1154560 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14199 {
14200 1049600 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14201 1049600 }
14202 104960 }
14203
14204 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14205
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion > 25)
14206 {
14207
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.txsz),f))
14208 {
14209 return qe_invalid;
14210 }
14211
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.tysz),f))
14212 {
14213 return qe_invalid;
14214 }
14215
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.hxsz),f))
14216 {
14217 return qe_invalid;
14218 }
14219
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.hysz),f))
14220 {
14221 return qe_invalid;
14222 }
14223
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.hzsz),f))
14224 {
14225 return qe_invalid;
14226 }
14227 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14228
14229 */
14230 93184 }
14231 //More Enemy Editor vars for 2.60
14232
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion > 26)
14233 {
14234
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.hxofs),f))
14235 {
14236 return qe_invalid;
14237 }
14238
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.hyofs),f))
14239 {
14240 return qe_invalid;
14241 }
14242
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.xofs),f))
14243 {
14244 return qe_invalid;
14245 }
14246
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.yofs),f))
14247 {
14248 return qe_invalid;
14249 }
14250
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.zofs),f))
14251 {
14252 return qe_invalid;
14253 }
14254 93184 }
14255
14256
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14257 {
14258 104960 tempguy.wpnsprite = 0;
14259 104960 }
14260
14261
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion > 27)
14262 {
14263
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.wpnsprite),f))
14264 {
14265 return qe_invalid;
14266 }
14267 93184 }
14268
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14269 {
14270 104960 tempguy.SIZEflags = 0;
14271 104960 }
14272
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion > 28)
14273 {
14274
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.SIZEflags),f))
14275 {
14276 return qe_invalid;
14277 }
14278
14279 93184 }
14280
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14281 {
14282 104960 tempguy.frozentile = 0;
14283 104960 tempguy.frozencset = 0;
14284 104960 tempguy.frozenclock = 0;
14285
2/2
✓ Branch 0 taken 1049600 times.
✓ Branch 1 taken 104960 times.
1154560 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14286 104960 }
14287
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion >= 30)
14288 {
14289
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.frozentile),f))
14290 {
14291 return qe_invalid;
14292 }
14293
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.frozencset),f))
14294 {
14295 return qe_invalid;
14296 }
14297
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.frozenclock),f))
14298 {
14299 return qe_invalid;
14300 }
14301
2/2
✓ Branch 0 taken 931840 times.
✓ Branch 1 taken 93184 times.
1025024 for ( int32_t q = 0; q < 10; q++ ) {
14302
1/2
✓ Branch 0 taken 931840 times.
✗ Branch 1 not taken.
931840 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14303 {
14304 return qe_invalid;
14305 }
14306 931840 }
14307
14308 93184 }
14309
14310
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion >= 34)
14311 {
14312
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetw(&(tempguy.firesfx),f))
14313 {
14314 return qe_invalid;
14315 }
14316
2/2
✓ Branch 0 taken 1584128 times.
✓ Branch 1 taken 93184 times.
1677312 for(int q=15;q<32;++q)
14317 {
14318
1/2
✓ Branch 0 taken 1584128 times.
✗ Branch 1 not taken.
1584128 if(!p_igetl(&(tempguy.attributes[q]),f))
14319 {
14320 return qe_invalid;
14321 }
14322 1584128 }
14323
14324
2/2
✓ Branch 0 taken 2981888 times.
✓ Branch 1 taken 93184 times.
3075072 for ( int32_t q = 0; q < 32; q++ ) {
14325
1/2
✓ Branch 0 taken 2981888 times.
✗ Branch 1 not taken.
2981888 if(!p_igetl(&(tempguy.movement[q]),f))
14326 {
14327 return qe_invalid;
14328 }
14329 2981888 }
14330
2/2
✓ Branch 0 taken 2981888 times.
✓ Branch 1 taken 93184 times.
3075072 for ( int32_t q = 0; q < 32; q++ ) {
14331
1/2
✓ Branch 0 taken 2981888 times.
✗ Branch 1 not taken.
2981888 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14332 {
14333 return qe_invalid;
14334 }
14335 2981888 }
14336
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetw(&(tempguy.script),f))
14337 {
14338 return qe_invalid;
14339 }
14340
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; q++ )
14341 {
14342
1/2
✓ Branch 0 taken 745472 times.
✗ Branch 1 not taken.
745472 if(!p_igetl(&(tempguy.initD[q]),f))
14343 {
14344 return qe_invalid;
14345 }
14346 745472 }
14347
2/2
✓ Branch 0 taken 186368 times.
✓ Branch 1 taken 93184 times.
279552 for ( int32_t q = 0; q < 2; q++ )
14348 {
14349 int32_t temp;
14350
1/2
✓ Branch 0 taken 186368 times.
✗ Branch 1 not taken.
186368 if(!p_igetl(&temp,f))
14351 {
14352 return qe_invalid;
14353 }
14354 186368 }
14355
14356 93184 }
14357
14358
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion >= 37)
14359 {
14360
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.editorflags),f))
14361 {
14362 return qe_invalid;
14363 }
14364 93184 }
14365
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14366
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion >= 38)
14367 {
14368
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.attributes[12]),f))
14369 {
14370 return qe_invalid;
14371 }
14372
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.attributes[13]),f))
14373 {
14374 return qe_invalid;
14375 }
14376
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.attributes[14]),f))
14377 {
14378 return qe_invalid;
14379 }
14380
14381 93184 }
14382
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion < 38 )
14383 {
14384 104960 tempguy.attributes[12] = 0;
14385 104960 tempguy.attributes[13] = 0;
14386 104960 tempguy.attributes[14] = 0;
14387 104960 }
14388
14389
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if ( guyversion >= 39 )
14390 {
14391
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; q++ )
14392 {
14393
2/2
✓ Branch 0 taken 48455680 times.
✓ Branch 1 taken 745472 times.
49201152 for ( int32_t w = 0; w < 65; w++ )
14394 {
14395
1/2
✓ Branch 0 taken 48455680 times.
✗ Branch 1 not taken.
48455680 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14396 {
14397 return qe_invalid;
14398 }
14399 48455680 }
14400
2/2
✓ Branch 0 taken 48455680 times.
✓ Branch 1 taken 745472 times.
49201152 for ( int32_t w = 0; w < 65; w++ )
14401 {
14402
1/2
✓ Branch 0 taken 48455680 times.
✗ Branch 1 not taken.
48455680 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14403 {
14404 return qe_invalid;
14405 }
14406 48455680 }
14407 745472 }
14408
14409
14410 93184 }
14411
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion < 39 ) //apply old InitD strings to both
14412 {
14413
2/2
✓ Branch 0 taken 839680 times.
✓ Branch 1 taken 104960 times.
944640 for ( int32_t q = 0; q < 8; q++ )
14414 {
14415 839680 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14416 839680 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14417 839680 }
14418 104960 }
14419
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if ( guyversion >= 40 )
14420 {
14421
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetw(&(tempguy.weaponscript),f))
14422 {
14423 return qe_invalid;
14424 }
14425 93184 }
14426
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion < 40 )
14427 {
14428 104960 tempguy.weaponscript = 0;
14429 104960 }
14430 //eweapon script InitD
14431
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if ( guyversion >= 41 )
14432 {
14433
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; q++ )
14434 {
14435
1/2
✓ Branch 0 taken 745472 times.
✗ Branch 1 not taken.
745472 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14436 {
14437 return qe_invalid;
14438 }
14439 745472 }
14440
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if ( guy_cversion < 4 )
14441 {
14442 if ( tempguy.family == eeKEESE )
14443 {
14444
14445 if ( !tempguy.attributes[0] )
14446 {
14447 tempguy.attributes[15] = 120;
14448 tempguy.attributes[16] = 16;
14449
14450 }
14451 }
14452 if ( tempguy.family == eePEAHAT )
14453 {
14454 tempguy.attributes[15] = 80;
14455 tempguy.attributes[16] = 16;
14456 }
14457
14458 if ( tempguy.family == eeGHINI )
14459 {
14460 tempguy.attributes[15] = 120;
14461 tempguy.attributes[16] = 10;
14462 }
14463
14464 }
14465 93184 }
14466
14467
14468
14469 //default weapon sprites (quest version < 2.54)
14470 //port over old defaults -Z
14471
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 32)
14472 {
14473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if ( tempguy.wpnsprite <= 0 )
14474 {
14475
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89121 times.
✓ Branch 4 taken 817 times.
✓ Branch 5 taken 708 times.
✓ Branch 6 taken 1938 times.
✓ Branch 7 taken 1316 times.
✓ Branch 8 taken 2445 times.
✓ Branch 9 taken 211 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 457 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 924 times.
✓ Branch 14 taken 1849 times.
✓ Branch 15 taken 234 times.
✓ Branch 16 taken 332 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1540 times.
104960 switch(tempguy.weapon)
14476 {
14477 case wNone:
14478 89121 tempguy.wpnsprite = 0; break;
14479
14480 case wSword:
14481 case wBeam:
14482 case wBrang:
14483 case wBomb:
14484 case wSBomb:
14485 case wLitBomb:
14486 case wLitSBomb:
14487 case wArrow:
14488 case wFire:
14489 case wWhistle:
14490 case wBait:
14491 case wWand:
14492 case wMagic:
14493 case wCatching:
14494 case wWind:
14495 case wRefMagic:
14496 case wRefFireball:
14497 case wRefRock:
14498 case wHammer:
14499 case wHookshot:
14500 case wHSHandle:
14501 case wHSChain:
14502 case wSSparkle:
14503 case wFSparkle:
14504 case wSmack:
14505 case wPhantom:
14506 case wCByrna:
14507 case wRefBeam:
14508 case wStomp:
14509 case lwMax:
14510 case wScript1:
14511 case wScript2:
14512 case wScript3:
14513 case wScript4:
14514 case wScript5:
14515 case wScript6:
14516 case wScript7:
14517 case wScript8:
14518 case wScript9:
14519 case wScript10:
14520 case wIce:
14521 //Cannot use any of these weapons yet.
14522 tempguy.wpnsprite = -1;
14523 break;
14524
14525 case wEnemyWeapons:
14526 2911 case ewFireball: tempguy.wpnsprite = 17; break;
14527
14528 817 case ewArrow: tempguy.wpnsprite = 19; break;
14529 708 case ewBrang: tempguy.wpnsprite = 4; break;
14530 1938 case ewSword: tempguy.wpnsprite = 20; break;
14531 1316 case ewRock: tempguy.wpnsprite = 18; break;
14532 2445 case ewMagic: tempguy.wpnsprite = 21; break;
14533 211 case ewBomb: tempguy.wpnsprite = 78; break;
14534 78 case ewSBomb: tempguy.wpnsprite = 79; break;
14535 457 case ewLitBomb: tempguy.wpnsprite = 76; break;
14536 79 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14537 924 case ewFireTrail: tempguy.wpnsprite = 80; break;
14538 1849 case ewFlame: tempguy.wpnsprite = 35; break;
14539 234 case ewWind: tempguy.wpnsprite = 36; break;
14540 332 case ewFlame2: tempguy.wpnsprite = 81; break;
14541 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14542 case ewIce: tempguy.wpnsprite = 83; break;
14543 1540 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14544
14545
14546 default: break; //No assign.
14547 }
14548 104960 }
14549 104960 }
14550
14551 //default weapon fire sound (quest version < 2.54)
14552 //port over old defaults and zero new data. -Z
14553
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 34)
14554 {
14555
2/2
✓ Branch 0 taken 3358720 times.
✓ Branch 1 taken 104960 times.
3463680 for ( int32_t q = 0; q < 32; q++ )
14556 {
14557 3358720 tempguy.movement[q] = 0;
14558 3358720 tempguy.new_weapon[q] = 0;
14559
14560 3358720 }
14561
14562 //NPC Script attributes.
14563 104960 tempguy.script = 0; //No scripted enemies existed. -Z
14564
2/2
✓ Branch 0 taken 839680 times.
✓ Branch 1 taken 104960 times.
944640 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14565
14566
2/2
✓ Branch 0 taken 1784320 times.
✓ Branch 1 taken 104960 times.
1889280 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14567
14568 //old default sounds
14569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if ( tempguy.firesfx <= 0 )
14570 {
14571
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89121 times.
✓ Branch 4 taken 817 times.
✓ Branch 5 taken 708 times.
✓ Branch 6 taken 1938 times.
✓ Branch 7 taken 1316 times.
✓ Branch 8 taken 2445 times.
✓ Branch 9 taken 211 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 457 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 924 times.
✓ Branch 14 taken 1849 times.
✓ Branch 15 taken 234 times.
✓ Branch 16 taken 332 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1540 times.
104960 switch(tempguy.weapon)
14572 {
14573 case wNone:
14574 89121 tempguy.firesfx = 0; break;
14575
14576 case wSword:
14577 case wBeam:
14578 case wBrang:
14579 case wBomb:
14580 case wSBomb:
14581 case wLitBomb:
14582 case wLitSBomb:
14583 case wArrow:
14584 case wFire:
14585 case wWhistle:
14586 case wBait:
14587 case wWand:
14588 case wMagic:
14589 case wCatching:
14590 case wWind:
14591 case wRefMagic:
14592 case wRefFireball:
14593 case wRefRock:
14594 case wHammer:
14595 case wHookshot:
14596 case wHSHandle:
14597 case wHSChain:
14598 case wSSparkle:
14599 case wFSparkle:
14600 case wSmack:
14601 case wPhantom:
14602 case wCByrna:
14603 case wRefBeam:
14604 case wStomp:
14605 case lwMax:
14606 case wScript1:
14607 case wScript2:
14608 case wScript3:
14609 case wScript4:
14610 case wScript5:
14611 case wScript6:
14612 case wScript7:
14613 case wScript8:
14614 case wScript9:
14615 case wScript10:
14616 case wIce:
14617 //Cannot use any of these weapons yet.
14618 tempguy.firesfx = -1;
14619 break;
14620
14621 case wEnemyWeapons:
14622 2911 case ewFireball: tempguy.firesfx = 40; break;
14623
14624 817 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14625 708 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14626 1938 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14627 1316 case ewRock: tempguy.firesfx = 51; break;
14628 2445 case ewMagic: tempguy.firesfx = 32; break;
14629 211 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14630 78 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14631 457 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14632 79 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14633 924 case ewFireTrail: tempguy.firesfx = 13; break;
14634 1849 case ewFlame: tempguy.firesfx = 13; break;
14635 234 case ewWind: tempguy.firesfx = 32; break;
14636 332 case ewFlame2: tempguy.firesfx = 13; break;
14637 case ewFlame2Trail: tempguy.firesfx = 13; break;
14638 case ewIce: tempguy.firesfx = 44; break;
14639 1540 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14640
14641 //what about special attacks (e.g. summoning == 56)
14642 default: break; //No assign.
14643 }
14644 104960 }
14645 104960 }
14646
14647 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14648
4/6
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 93184 times.
198144 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14649 {
14650
2/2
✓ Branch 0 taken 14184 times.
✓ Branch 1 taken 90776 times.
104960 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14651 104960 }
14652 //Keese and bat halt rates.
14653
3/4
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104960 times.
198144 if ( guyversion < 42 && guy_cversion < 4 )
14654 {
14655
14656
2/2
✓ Branch 0 taken 103636 times.
✓ Branch 1 taken 1324 times.
104960 if ( tempguy.family == eeKEESE )
14657 {
14658
14659
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 955 times.
1324 if ( !tempguy.attributes[0] )
14660 {
14661 955 tempguy.attributes[15] = 120;
14662 955 tempguy.attributes[16] = 16;
14663
14664 955 }
14665 1324 }
14666
2/2
✓ Branch 0 taken 104486 times.
✓ Branch 1 taken 474 times.
104960 if ( tempguy.family == eePEAHAT )
14667 {
14668 474 tempguy.attributes[15] = 80;
14669 474 tempguy.attributes[16] = 16;
14670 474 }
14671
2/2
✓ Branch 0 taken 104755 times.
✓ Branch 1 taken 205 times.
104960 if ( tempguy.family == eeGHINI )
14672 {
14673 205 tempguy.attributes[15] = 120;
14674 205 tempguy.attributes[16] = 10;
14675 205 }
14676
14677
14678 104960 }
14679
14680
14681 //miscellaneous other corrections
14682 //fix the mirror wizzrobe -DD
14683
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 7)
14684 {
14685 if(i == eMWIZ)
14686 {
14687 tempguy.attributes[1] = 0;
14688 tempguy.attributes[3] = 1;
14689 }
14690 }
14691
14692
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 8)
14693 {
14694 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14695 {
14696 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14697 tempguy.attributes[4] = 4; //neck length in segments
14698 tempguy.attributes[5] = 8; //neck offset from first body tile
14699 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14700 tempguy.attributes[7] = 168; //head offset from first body tile
14701 tempguy.attributes[8] = 228; //flying head offset from first body tile
14702
14703 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14704 {
14705 tempguy.attributes[5] += 10; //neck offset from first body tile
14706 tempguy.attributes[7] -= 12; //head offset from first body tile
14707 }
14708 }
14709 }
14710
14711
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14712 {
14713 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.attributes[0]==0)
14714 tempguy.bosspal = spDIG;
14715 }
14716
14717
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 11) // December 2007 - Spinning Tile fix
14718 {
14719 if(tempguy.family==eeSPINTILE)
14720 {
14721 tempguy.flags |= guy_superman;
14722 tempguy.item_set = 0; // Don't drop items
14723 tempguy.step = 300;
14724 }
14725 }
14726
14727
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14728 {
14729 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14730 {
14731 if(tempguy.family==eeROPE)
14732 {
14733 tempguy.flags &= ~guy_flashing;
14734 }
14735 }
14736
14737 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14738 {
14739 if(tempguy.family==eeBUBBLE)
14740 {
14741 tempguy.flags &= ~guy_flashing;
14742 }
14743 }
14744
14745 if((tempguy.family==eeGHINI)&&(tempguy.attributes[0]))
14746 {
14747 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14748 {
14749 tempguy.flags |= guy_blinking;
14750 }
14751
14752 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14753 {
14754 tempguy.flags |= guy_transparent;
14755 }
14756 }
14757 }
14758
14759
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14760 {
14761 if(i==gFIRE)
14762 {
14763 tempguy.e_anim = aFLIP;
14764 tempguy.e_frate = 24;
14765 }
14766
14767 if(i==gFAIRY)
14768 {
14769 tempguy.e_anim = a2FRM;
14770 tempguy.e_frate = 16;
14771 }
14772 }
14773
14774
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14775 {
14776 if(i==0) Z_message("Updating guys to version 16...\n");
14777
14778 update_guy_1(&tempguy);
14779
14780 if(i==eMPOLSV)
14781 {
14782 tempguy.defense[edefARROW] = edCHINK;
14783 tempguy.defense[edefMAGIC] = ed1HKO;
14784 tempguy.defense[edefREFMAGIC] = ed1HKO;
14785 }
14786 }
14787
14788
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 17) // December 2009
14789 {
14790 if(tempguy.family==eePROJECTILE)
14791 {
14792 tempguy.attributes[0] = 0;
14793 }
14794 }
14795
14796
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 18) // January 2010
14797 {
14798 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14799 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14800
14801 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14802 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14803
14804 if(tempguy.family == eeAQUA)
14805 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14806 else if(tempguy.family == eeMANHAN)
14807 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14808 else if(tempguy.family==eePATRA)
14809 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14810 else if(tempguy.family==eeGHOMA)
14811 {
14812 for(int32_t j=0; j<edefLAST; j++)
14813 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14814
14815 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
14816
14817 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14818
14819 tempguy.attributes[0]--;
14820 }
14821 else if(tempguy.family == eeGLEEOK)
14822 {
14823 for(int32_t j=0; j<edefLAST; j++)
14824 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14825
14826 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14827 }
14828 else if(tempguy.family == eeARMOS)
14829 {
14830 tempguy.family=eeWALK;
14831 tempguy.hrate = 0;
14832 tempguy.attributes[9] = tempguy.attributes[0];
14833 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14834 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14835 tempguy.attributes[8] = e9tARMOS;
14836 }
14837 else if(tempguy.family == eeGHINI && !tempguy.attributes[0])
14838 {
14839 tempguy.family=eeWALK;
14840 tempguy.hrate = 0;
14841 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
14842 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
14843 }
14844
14845 // Spawn animation flags
14846 if(tempguy.family == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
14847 tempguy.flags |= guy_fade_flicker;
14848 else
14849 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
14850 }
14851
14852
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 20) // April 2010
14853 {
14854 if(tempguy.family == eeTRAP)
14855 {
14856 tempguy.attributes[1] = tempguy.attributes[9];
14857
14858 if(tempguy.attributes[9]>=1)
14859 {
14860 tempguy.attributes[0]++;
14861 }
14862
14863 tempguy.attributes[9] = 0;
14864 }
14865
14866 // Bomb Blast fix
14867 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14868 tempguy.weapon = ewLitBomb;
14869 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14870 tempguy.weapon = ewLitSBomb;
14871 }
14872
14873
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 21) // September 2011
14874 {
14875 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14876 {
14877 if(tempguy.family == eeKEESETRIB)
14878 {
14879 tempguy.family = eeKEESE;
14880 tempguy.attributes[1] = e2tKEESETRIB;
14881 tempguy.attributes[0] = 0;
14882 }
14883
14884 tempguy.rate = 2;
14885 tempguy.hrate = 8;
14886 tempguy.homing = 0;
14887 tempguy.step= (tempguy.family == eeKEESE && tempguy.attributes[0] ? 100:62);
14888 }
14889 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14890 {
14891 if(tempguy.family == eePEAHAT)
14892 {
14893 tempguy.rate = 4;
14894 tempguy.step = 62;
14895 }
14896 else
14897 tempguy.step = 25;
14898
14899 tempguy.hrate = 8;
14900 tempguy.homing = 0;
14901 }
14902 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14903 {
14904 if(tempguy.family == eeMANHAN)
14905 tempguy.step=50;
14906
14907 tempguy.hrate = 16;
14908 tempguy.homing = 0;
14909 }
14910 else if(tempguy.family == eeGLEEOK)
14911 {
14912 tempguy.rate = 2;
14913 tempguy.homing = 0;
14914 tempguy.hrate = 9;
14915 tempguy.step=89;
14916 }
14917 else if(tempguy.family == eeGHINI)
14918 {
14919 tempguy.rate = 4;
14920 tempguy.hrate = 12;
14921 tempguy.step=62;
14922 tempguy.homing = 0;
14923 }
14924
14925 // Bigdig random rate fix
14926 if(tempguy.family==eeDIG && tempguy.attributes[9]==1)
14927 {
14928 tempguy.rate = 2;
14929 }
14930 }
14931
14932
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 24) // November 2012
14933 {
14934 if(tempguy.family==eeLANM)
14935 tempguy.attributes[2] = 1;
14936 else if(tempguy.family==eeMOLD)
14937 tempguy.attributes[1] = 0;
14938 }
14939
14940
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14941 {
14942
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 103530 times.
104960 if(tempguy.family!=eeDIG)
14943 {
14944 103530 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14945 103530 }
14946
14947 104960 }
14948 // does not seem to solve the issue!
14949
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if ( Header->zelda_version <= 0x210 )
14950 {
14951 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14952 if ( tempguy.family == eeDONGO )
14953 {
14954 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14955 }
14956 }
14957
14958
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion >= 42)
14959 {
14960
2/2
✓ Branch 0 taken 90624 times.
✓ Branch 1 taken 2560 times.
93184 if(guyversion >= 47)
14961 {
14962
1/2
✓ Branch 0 taken 90624 times.
✗ Branch 1 not taken.
90624 if(!p_igetl(&(tempguy.moveflags),f))
14963 {
14964 return qe_invalid;
14965 }
14966 90624 }
14967 else
14968 {
14969 byte fl;
14970
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
14971 {
14972 return qe_invalid;
14973 }
14974 2560 tempguy.moveflags = (move_flags)fl;
14975 }
14976 93184 }
14977 else
14978 {
14979
7/8
✓ Branch 0 taken 3146 times.
✓ Branch 1 taken 82805 times.
✓ Branch 2 taken 2767 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 970 times.
✓ Branch 5 taken 655 times.
✓ Branch 6 taken 508 times.
✓ Branch 7 taken 14109 times.
104960 switch(tempguy.family)
14980 {
14981 //No gravity; floats over pits
14982 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14983 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14984 //Special (bosses, etc)
14985 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14986 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14987 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14988 82805 tempguy.moveflags = move_can_pitwalk;
14989 82805 break;
14990 //No gravity, but falls in pits
14991 case eeLEV:
14992 970 tempguy.moveflags = move_can_pitfall;
14993 970 break;
14994 //Bosses that respect pits
14995 case eeDONGO:
14996 655 tempguy.moveflags = move_obeys_grav;
14997 655 break;
14998 case eeLANM:
14999 508 tempguy.moveflags = move_none;
15000 508 break;
15001 //Gravity, floats over pits
15002 case eeWIZZ: case eeWALLM: case eeGHINI:
15003 2767 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15004 2767 break;
15005 //Gravity and falls in pits
15006 case eeWALK:
15007
4/4
✓ Branch 0 taken 13399 times.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 538 times.
✓ Branch 3 taken 12861 times.
14109 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15008 1248 break;
15009 [[fallthrough]];
15010 case eeOTHER:
15011 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15012 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15013 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15014 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15015 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15016 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15017 16007 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15018 16007 }
15019 }
15020
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 43)
15021 {
15022
2/2
✓ Branch 0 taken 85572 times.
✓ Branch 1 taken 19388 times.
104960 switch(tempguy.family)
15023 {
15024 //No gravity; floats over pits
15025 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15026 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15027 //Special (bosses, etc)
15028 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15029 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15030 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15031 case eeWIZZ: case eeWALLM: case eeGHINI:
15032 //Gravity, floats over pits
15033 85572 tempguy.moveflags |= move_can_waterwalk;
15034 85572 tempguy.moveflags |= move_can_pitwalk;
15035 85572 break;
15036 }
15037 104960 }
15038
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if (guyversion < 44)
15039 {
15040
2/2
✓ Branch 0 taken 104028 times.
✓ Branch 1 taken 932 times.
104960 if ( tempguy.family == eeGHOMA )
15041 {
15042 932 tempguy.flags |= guy_fade_instant;
15043 932 }
15044 104960 }
15045
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if (guyversion > 44)
15046 {
15047
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_getc(&(tempguy.spr_shadow),f))
15048 {
15049 return qe_invalid;
15050 }
15051
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_getc(&(tempguy.spr_death),f))
15052 {
15053 return qe_invalid;
15054 }
15055
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_getc(&(tempguy.spr_spawn),f))
15056 {
15057 return qe_invalid;
15058 }
15059 93184 }
15060 else
15061 {
15062
2/2
✓ Branch 0 taken 104553 times.
✓ Branch 1 taken 407 times.
104960 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15063 104960 tempguy.spr_death = iwDeath;
15064 104960 tempguy.spr_spawn = iwSpawn;
15065 }
15066
15067
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 46)
15068 {
15069
4/4
✓ Branch 0 taken 14109 times.
✓ Branch 1 taken 90851 times.
✓ Branch 2 taken 13399 times.
✓ Branch 3 taken 710 times.
104960 if(tempguy.family == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15070 {
15071 710 tempguy.moveflags |= move_can_waterwalk;
15072 710 }
15073 104960 }
15074
15075
2/2
✓ Branch 0 taken 90624 times.
✓ Branch 1 taken 107520 times.
198144 if (guyversion < 47)
15076 {
15077
4/4
✓ Branch 0 taken 1460 times.
✓ Branch 1 taken 106060 times.
✓ Branch 2 taken 876 times.
✓ Branch 3 taken 584 times.
107520 if (tempguy.family == eeDIG && tempguy.attributes[9]!=1)
15078 {
15079 584 tempguy.flags |= guy_ignore_kill_all;
15080 584 }
15081 107520 }
15082
15083
2/2
✓ Branch 0 taken 70144 times.
✓ Branch 1 taken 128000 times.
198144 if (guyversion < 49)
15084 {
15085
8/8
✓ Branch 0 taken 16638 times.
✓ Branch 1 taken 111362 times.
✓ Branch 2 taken 16157 times.
✓ Branch 3 taken 481 times.
✓ Branch 4 taken 15665 times.
✓ Branch 5 taken 492 times.
✓ Branch 6 taken 537 times.
✓ Branch 7 taken 15128 times.
128000 if (tempguy.family == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15086 {
15087
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 727 times.
✓ Branch 3 taken 61 times.
1510 switch (tempguy.attributes[7]) {
15088 case 0: //Sword
15089 722 tempguy.attributes[7] = e8tSWORD;
15090 722 break;
15091 case 1: //Item
15092 727 tempguy.attributes[7] = e8tITEM;
15093 727 break;
15094 case 2: //Both
15095 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15096 61 break;
15097 default: //this can actually happen since Misc8 can be set to any number.
15098 tempguy.attributes[7] = 0;
15099 break;
15100 }
15101 1510 }
15102 128000 }
15103
15104 //these could possible be combined but rather be safe...
15105
2/2
✓ Branch 0 taken 70144 times.
✓ Branch 1 taken 128000 times.
198144 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15106 {
15107 128000 guy_update_firesfx(tempguy);
15108 128000 }
15109
2/2
✓ Branch 0 taken 128000 times.
✓ Branch 1 taken 70144 times.
198144 if (guyversion < 52)
15110 {
15111 128000 guy_update_weaponflags(tempguy);
15112 128000 }
15113 else
15114 {
15115
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_getc(&(tempguy.wunblockable), f))
15116 return qe_invalid;
15117
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.wmoveflags), f))
15118 return qe_invalid;
15119
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weapoverrideFLAGS), f))
15120 return qe_invalid;
15121
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_tilew), f))
15122 return qe_invalid;
15123
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_tileh), f))
15124 return qe_invalid;
15125
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_hxsz), f))
15126 return qe_invalid;
15127
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_hysz), f))
15128 return qe_invalid;
15129
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_hzsz), f))
15130 return qe_invalid;
15131
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_hxofs), f))
15132 return qe_invalid;
15133
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_hyofs), f))
15134 return qe_invalid;
15135
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_xofs), f))
15136 return qe_invalid;
15137
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_yofs), f))
15138 return qe_invalid;
15139
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.wstep), f))
15140 return qe_invalid;
15141
2/2
✓ Branch 0 taken 350720 times.
✓ Branch 1 taken 70144 times.
420864 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15142 {
15143
1/2
✓ Branch 0 taken 350720 times.
✗ Branch 1 not taken.
350720 if (!p_igetw(&(tempguy.burnsprs[q]), f))
15144 return qe_invalid;
15145
1/2
✓ Branch 0 taken 350720 times.
✗ Branch 1 not taken.
350720 if (!p_igetw(&(tempguy.light_rads[q]), f))
15146 return qe_invalid;
15147 350720 }
15148 }
15149
2/2
✓ Branch 0 taken 128000 times.
✓ Branch 1 taken 70144 times.
198144 if (guyversion < 53)
15150 {
15151 128000 guy_update_weaponspecialsfx(tempguy);
15152 128000 }
15153 else
15154 {
15155
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_getc(&(tempguy.specialsfx), f))
15156 return qe_invalid;
15157 }
15158
15159
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15160 {
15161 tempguy.script = 0;
15162 for(int q = 0; q < 8; ++q)
15163 tempguy.initD[q] = 0;
15164 }
15165 198144 guysbuf[i] = tempguy;
15166 198144 }
15167 387 }
15168
15169 387 return 0;
15170 469 }
15171
15172 void update_guy_1(guydata *tempguy) // November 2009
15173 {
15174 bool doesntcount = false;
15175 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15176
15177 switch(tempguy->family)
15178 {
15179 case 1: //eeWALK
15180 switch(tempguy->attributes[9])
15181 {
15182 case 0: //Stalfos
15183 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15184 tempguy->attributes[0]=4;
15185
15186 break;
15187
15188 case 1: //Darknut
15189 goto darknuts;
15190 break;
15191 }
15192
15193 tempguy->attributes[9] = 0;
15194 break;
15195
15196 case 2: //eeSHOOT
15197 tempguy->family = eeWALK;
15198
15199 switch(tempguy->attributes[9])
15200 {
15201 case 0: //Octorok
15202 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15203 {
15204 tempguy->attributes[0]=e1tFIREOCTO;
15205 tempguy->attributes[1]=e2tFIREOCTO;
15206 }
15207 else tempguy->attributes[0] = 0;
15208
15209 tempguy->attributes[5]=tempguy->attributes[3];
15210 tempguy->attributes[3]=tempguy->attributes[2];
15211 tempguy->attributes[2]=0;
15212 break;
15213
15214 case 1: // Moblin
15215 tempguy->attributes[0] = 0;
15216 break;
15217
15218 case 2: //Lynel
15219 tempguy->attributes[5]=tempguy->attributes[0]+1;
15220 tempguy->attributes[0]=0;
15221 break;
15222
15223 case 3: //Stalfos 2
15224 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15225 tempguy->attributes[0]=e1t4SHOTS;
15226 else tempguy->attributes[0] = 0;
15227
15228 break;
15229
15230 case 4: //Darknut 5
15231 darknuts:
15232 tempguy->defense[edefFIRE] = edIGNORE;
15233 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15234 tempguy->defense[edefHOOKSHOT] = 0;
15235 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15236 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15237
15238 if(tempguy->attributes[0]==1)
15239 tempguy->attributes[0]=2;
15240 else if(tempguy->attributes[0]==2)
15241 {
15242 tempguy->attributes[3]=tempguy->attributes[2];
15243 tempguy->attributes[2]=tempguy->attributes[1];
15244 tempguy->attributes[1]=e2tSPLIT;
15245 tempguy->attributes[0] = 0;
15246 }
15247 else tempguy->attributes[0] = 0;
15248
15249 tempguy->flags |= guy_shield_front;
15250
15251 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15252 tempguy->flags &= ~guy_bkshield;
15253 else
15254 tempguy->flags |= guy_bkshield;
15255
15256 break;
15257 }
15258
15259 tempguy->attributes[9] = 0;
15260 break;
15261
15262 /*
15263 case 9: //eeARMOS
15264 tempguy->family = eeWALK;
15265 break;
15266 */
15267 case 11: //eeGEL
15268 case 33: //eeGELTRIB
15269 if(tempguy->family==33)
15270 {
15271 tempguy->attributes[3] = 1;
15272
15273 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15274 tempguy->attributes[2] = tempguy->attributes[1];
15275
15276 tempguy->attributes[1] = e2tTRIBBLE;
15277 }
15278 else
15279 {
15280 tempguy->attributes[3] = 0;
15281 tempguy->attributes[2] = 0;
15282 tempguy->attributes[1] = 0;
15283 }
15284
15285 tempguy->family = eeWALK;
15286
15287 if(tempguy->attributes[0])
15288 {
15289 tempguy->attributes[0]=1;
15290 tempguy->weapon = ewFireTrail;
15291 }
15292
15293 break;
15294
15295 case 34: //eeZOLTRIB
15296 case 12: //eeZOL
15297 tempguy->attributes[3]=tempguy->attributes[2];
15298 tempguy->attributes[2]=tempguy->attributes[1];
15299 tempguy->family = eeWALK;
15300 tempguy->attributes[1]=e2tSPLITHIT;
15301
15302 if(tempguy->attributes[0])
15303 {
15304 tempguy->attributes[0]=1;
15305 tempguy->weapon = ewFireTrail;
15306 }
15307
15308 break;
15309
15310 case 13: //eeROPE
15311 tempguy->family = eeWALK;
15312 tempguy->attributes[8] = e9tROPE;
15313
15314 if(tempguy->attributes[0])
15315 {
15316 tempguy->attributes[3] = tempguy->attributes[2];
15317 tempguy->attributes[2] = tempguy->attributes[1];
15318 tempguy->attributes[1] = e2tBOMBCHU;
15319 }
15320
15321 tempguy->attributes[0] = 0;
15322 break;
15323
15324 case 14: //eeGORIYA
15325 tempguy->family = eeWALK;
15326
15327 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15328
15329 break;
15330
15331 case 17: //eeBUBBLE
15332 tempguy->family = eeWALK;
15333 tempguy->attributes[7] = tempguy->attributes[1];
15334 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15335 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15336
15337 //fallthrogh
15338 case eeTRAP:
15339 case eeROCK:
15340 doesntcount = true;
15341 break;
15342
15343 case 35: //eeVIRETRIB
15344 case 18: //eeVIRE
15345 tempguy->family = eeWALK;
15346 tempguy->attributes[3]=tempguy->attributes[2];
15347 tempguy->attributes[2]=tempguy->attributes[1];
15348 tempguy->attributes[1]=e2tSPLITHIT;
15349 tempguy->attributes[8]=e9tVIRE;
15350 break;
15351
15352 case 19: //eeLIKE
15353 tempguy->family = eeWALK;
15354 tempguy->attributes[6] = e7tEATITEMS;
15355 tempguy->attributes[7]=95;
15356 break;
15357
15358 case 20: //eePOLSV
15359 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15360 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15361 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15362 tempguy->defense[edefARROW] = ed1HKO;
15363 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15364 tempguy->family = eeWALK;
15365 tempguy->attributes[8] = e9tPOLSVOICE;
15366 tempguy->rate = 4;
15367 tempguy->homing = 32;
15368 tempguy->hrate = 10;
15369 tempguy->grumble = 0;
15370 break;
15371
15372 case eeWIZZ:
15373 if(tempguy->attributes[3])
15374 {
15375 for(int32_t i=0; i < edefLAST; i++)
15376 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15377 }
15378 else
15379 {
15380 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15381 tempguy->defense[edefMAGIC] = edCHINK;
15382 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15383 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15384 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15385 }
15386
15387 break;
15388
15389 case eePEAHAT:
15390 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15391
15392 if(!(tempguy->flags & guy_bhit))
15393 tempguy->defense[edefBRANG] = edSTUNONLY;
15394
15395 break;
15396
15397 case eeLEV:
15398 tempguy->defense[edefSTOMP] = edCHINK;
15399 break;
15400 }
15401
15402 // Old flags
15403 if(tempguy->flags & guy_superman)
15404 {
15405 for(int32_t i = 0; i < edefLAST; i++)
15406 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15407 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15408 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15409 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15410 }
15411
15412 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15413
15414 if(doesntcount)
15415 tempguy->flags |= (guy_doesnt_count);
15416 }
15417
15418 1186472 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
15419 {
15420 byte tempbyte, padding;
15421 int32_t extras, secretcombos;
15422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->valid),f))
15423 {
15424 return qe_invalid;
15425 }
15426
15427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->guy),f))
15428 return qe_invalid;
15429 1186472 temp_mapscr->guytile = -1; //signal to use default guy values
15430
2/2
✓ Branch 0 taken 1185873 times.
✓ Branch 1 taken 599 times.
1186472 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15431
4/4
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 1185873 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 539 times.
1186472 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15432
15433
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15434 {
15435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15436 {
15437 return qe_invalid;
15438 }
15439
15440 22176 temp_mapscr->str=tempbyte;
15441 22176 }
15442 else
15443 {
15444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164296 times.
1164296 if(!p_igetw(&(temp_mapscr->str),f))
15445 {
15446 return qe_invalid;
15447 }
15448 }
15449
15450
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->room),f))
15451 {
15452 return qe_invalid;
15453 }
15454
15455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->item),f))
15456 {
15457 return qe_invalid;
15458 }
15459
15460
3/6
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 657968 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15461 {
15462 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15463 528504 }
15464 else
15465 {
15466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->hasitem),f))
15467 return qe_invalid;
15468 }
15469
15470
3/4
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1189192 if((Header->zelda_version < 0x192)||
15471
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
1164296 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15472 {
15473
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15474 {
15475 return qe_invalid;
15476 }
15477 22176 }
15478
15479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15480 {
15481 return qe_invalid;
15482 }
15483
15484
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15485 {
15486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15487 {
15488 return qe_invalid;
15489 }
15490 24896 }
15491
15492
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15493 {
15494
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15495 {
15496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15497 {
15498 return qe_invalid;
15499 }
15500 1973904 }
15501 657968 }
15502 else
15503 {
15504 528504 temp_mapscr->tilewarptype[1]=0;
15505 528504 temp_mapscr->tilewarptype[2]=0;
15506 528504 temp_mapscr->tilewarptype[3]=0;
15507 }
15508
15509
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15510 {
15511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164296 times.
1164296 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15512 {
15513 return qe_invalid;
15514 }
15515 1164296 }
15516
15517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15518 {
15519 return qe_invalid;
15520 }
15521
15522 1186472 temp_mapscr->warpreturnx[1]=0;
15523 1186472 temp_mapscr->warpreturnx[2]=0;
15524 1186472 temp_mapscr->warpreturnx[3]=0;
15525
15526
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15527 {
15528
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15529 {
15530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15531 {
15532 return qe_invalid;
15533 }
15534 1973904 }
15535 657968 }
15536
15537
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15538 {
15539 return qe_invalid;
15540 }
15541
15542 1186472 temp_mapscr->warpreturny[1]=0;
15543 1186472 temp_mapscr->warpreturny[2]=0;
15544 1186472 temp_mapscr->warpreturny[3]=0;
15545
15546
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15547 {
15548
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15549 {
15550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15551 {
15552 return qe_invalid;
15553 }
15554 1973904 }
15555
15556
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(version>=18)
15557 {
15558
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15559 {
15560 return qe_invalid;
15561 }
15562 657968 }
15563 else
15564 {
15565 byte temp;
15566
15567 if(!p_getc(&temp,f))
15568 {
15569 return qe_invalid;
15570 }
15571
15572 temp_mapscr->warpreturnc=temp<<8|temp;
15573 }
15574 657968 }
15575
15576
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->stairx),f))
15577
15578 {
15579 return qe_invalid;
15580 }
15581
15582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->stairy),f))
15583 {
15584 return qe_invalid;
15585 }
15586
15587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->itemx),f))
15588 {
15589 return qe_invalid;
15590 }
15591
15592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->itemy),f))
15593 {
15594 return qe_invalid;
15595 }
15596
15597
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version > 15) // February 2009
15598 {
15599
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->color),f))
15600 {
15601 return qe_invalid;
15602 }
15603 657968 }
15604 else
15605 {
15606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15607 {
15608 return qe_invalid;
15609 }
15610
15611 528504 temp_mapscr->color = (word) tempbyte;
15612 }
15613
15614
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->flags11),f))
15615 {
15616 return qe_invalid;
15617 }
15618
15619
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
15620 {
15621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4745888 times.
4745888 if(!p_getc(&(temp_mapscr->door[k]),f))
15622 {
15623 return qe_invalid;
15624
15625 }
15626 4745888 }
15627
15628
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version <= 11)
15629 {
15630
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15631 {
15632 return qe_invalid;
15633 }
15634
15635 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15636
15637
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15638 {
15639 for(int32_t i=1; i<4; i++)
15640 {
15641 if(!p_getc(&(tempbyte),f))
15642 {
15643 return qe_invalid;
15644 }
15645
15646 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15647 }
15648 }
15649 else
15650 {
15651 528504 temp_mapscr->tilewarpdmap[1]=0;
15652 528504 temp_mapscr->tilewarpdmap[2]=0;
15653 528504 temp_mapscr->tilewarpdmap[3]=0;
15654 }
15655 528504 }
15656 else
15657 {
15658
2/2
✓ Branch 0 taken 2631872 times.
✓ Branch 1 taken 657968 times.
3289840 for(int32_t i=0; i<4; i++)
15659 {
15660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2631872 times.
2631872 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15661 {
15662 return qe_invalid;
15663 }
15664 2631872 }
15665 }
15666
15667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15668 {
15669 return qe_invalid;
15670 }
15671
15672
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15673 {
15674
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15675 {
15676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15677 {
15678 return qe_invalid;
15679 }
15680 1973904 }
15681 657968 }
15682 else
15683 {
15684 528504 temp_mapscr->tilewarpscr[1]=0;
15685 528504 temp_mapscr->tilewarpscr[2]=0;
15686 528504 temp_mapscr->tilewarpscr[3]=0;
15687 }
15688
15689
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version >= 15)
15690 {
15691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15692 {
15693 return qe_invalid;
15694 }
15695 657968 }
15696 else
15697 {
15698 528504 temp_mapscr->tilewarpoverlayflags=0;
15699 }
15700
15701
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->exitdir),f))
15702 {
15703 return qe_invalid;
15704 }
15705
15706
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15707 {
15708
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15709 {
15710 return qe_invalid;
15711 }
15712
15713 24896 }
15714
15715
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15716 {
15717 if(!p_getc(&padding,f))
15718 {
15719 return qe_invalid;
15720 }
15721 }
15722
15723
2/2
✓ Branch 0 taken 11864720 times.
✓ Branch 1 taken 1186472 times.
13051192 for(int32_t k=0; k<10; k++)
15724 {
15725
5/6
✓ Branch 0 taken 11642960 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11615760 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11864720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15726 {
15727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15728 {
15729 return qe_invalid;
15730 }
15731
15732 221760 temp_mapscr->enemy[k]=tempbyte;
15733 221760 }
15734 else
15735 {
15736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11642960 times.
11642960 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15737 {
15738 return qe_invalid;
15739 }
15740 }
15741
15742
5/6
✓ Branch 0 taken 11642960 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11615760 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11864720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15743 {
15744 //using enumerations here is dangerous
15745 //very easy to break old quests -DD
15746
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15747 {
15748 1342 temp_mapscr->enemy[k]+=5;
15749 1342 }
15750
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15751 {
15752 94 temp_mapscr->enemy[k]+=1;
15753 94 }
15754 221760 }
15755
15756
2/2
✓ Branch 0 taken 6579680 times.
✓ Branch 1 taken 5285040 times.
11864720 if(version < 9)
15757 {
15758
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15759 {
15760 275905 temp_mapscr->enemy[k]+=10;
15761 275905 }
15762 5285040 }
15763 //don't read in any invalid data
15764
2/2
✓ Branch 0 taken 11864270 times.
✓ Branch 1 taken 450 times.
11864720 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15765 {
15766 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15767 450 temp_mapscr->enemy[k] = 0;
15768 450 }
15769 11864720 }
15770
15771
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->pattern),f))
15772 {
15773 return qe_invalid;
15774 }
15775
15776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15777 {
15778 return qe_invalid;
15779 }
15780
15781
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15782 {
15783
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15784 {
15785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15786 {
15787 return qe_invalid;
15788 }
15789 1973904 }
15790 657968 }
15791 else
15792 {
15793 528504 temp_mapscr->sidewarptype[1]=0;
15794 528504 temp_mapscr->sidewarptype[2]=0;
15795 528504 temp_mapscr->sidewarptype[3]=0;
15796 }
15797
15798
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version >= 15)
15799 {
15800
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15801 {
15802 return qe_invalid;
15803 }
15804 657968 }
15805 else
15806 {
15807 528504 temp_mapscr->sidewarpoverlayflags=0;
15808 }
15809
15810
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15811 {
15812 return qe_invalid;
15813 }
15814
15815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15816 {
15817 return qe_invalid;
15818 }
15819
15820
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
15821 {
15822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4745888 times.
4745888 if(!p_getc(&(temp_mapscr->path[k]),f))
15823 {
15824 return qe_invalid;
15825 }
15826 4745888 }
15827
15828
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15829 {
15830 return qe_invalid;
15831 }
15832
15833
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15834 {
15835
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 1973904 times.
2631872 for(int32_t i=1; i<4; i++)
15836 {
15837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15838 {
15839 return qe_invalid;
15840 }
15841 1973904 }
15842 657968 }
15843 else
15844 {
15845 528504 temp_mapscr->sidewarpscr[1]=0;
15846 528504 temp_mapscr->sidewarpscr[2]=0;
15847 528504 temp_mapscr->sidewarpscr[3]=0;
15848 }
15849
15850
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version <= 11)
15851 {
15852
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15853 {
15854 return qe_invalid;
15855 }
15856
15857 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15858
15859
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15860 {
15861 for(int32_t i=1; i<4; i++)
15862 {
15863 if(!p_getc(&(tempbyte),f))
15864 {
15865 return qe_invalid;
15866 }
15867
15868 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15869 }
15870 }
15871 else
15872 {
15873 528504 temp_mapscr->sidewarpdmap[1]=0;
15874 528504 temp_mapscr->sidewarpdmap[2]=0;
15875 528504 temp_mapscr->sidewarpdmap[3]=0;
15876 }
15877 528504 }
15878 else
15879 {
15880
2/2
✓ Branch 0 taken 2631872 times.
✓ Branch 1 taken 657968 times.
3289840 for(int32_t i=0; i<4; i++)
15881 {
15882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2631872 times.
2631872 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15883 {
15884 return qe_invalid;
15885 }
15886 2631872 }
15887 }
15888
15889
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15890 {
15891
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15892 {
15893 return qe_invalid;
15894 }
15895 657968 }
15896 528504 else temp_mapscr->sidewarpindex = 0;
15897
15898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_igetw(&(temp_mapscr->undercombo),f))
15899 {
15900 return qe_invalid;
15901 }
15902
15903
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15904 {
15905
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_pages[scrind], f))
15906 {
15907 return qe_invalid;
15908 }
15909 24896 }
15910
15911
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15912 {
15913 return qe_invalid;
15914 }
15915
15916
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_igetw(&(temp_mapscr->catchall),f))
15917 {
15918 return qe_invalid;
15919 }
15920
15921
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->flags),f))
15922 {
15923 return qe_invalid;
15924 }
15925
15926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->flags2),f))
15927 {
15928 return qe_invalid;
15929 }
15930
15931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->flags3),f))
15932 {
15933 return qe_invalid;
15934 }
15935
15936
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15937 //if (version>2)
15938 {
15939
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags4),f))
15940 {
15941 return qe_invalid;
15942 }
15943 657968 }
15944
15945
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15946 {
15947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags5),f))
15948 {
15949 return qe_invalid;
15950 }
15951
15952
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->noreset),f))
15953 {
15954 return qe_invalid;
15955 }
15956
15957
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->nocarry),f))
15958 {
15959 return qe_invalid;
15960 }
15961
15962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(temp_mapscr->flags5&32)
15963 {
15964 temp_mapscr->flags5 &= ~32;
15965 temp_mapscr->noreset |= 48;
15966 }
15967
15968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(version<8)
15969 {
15970 if(temp_mapscr->noreset&1)
15971 {
15972 temp_mapscr->noreset|=8192;
15973 }
15974
15975 if(temp_mapscr->nocarry&1)
15976 {
15977 temp_mapscr->nocarry|=8192;
15978 temp_mapscr->nocarry&=~1;
15979 }
15980 }
15981 657968 }
15982 else
15983 {
15984 528504 temp_mapscr->flags5 = 0;
15985 528504 temp_mapscr->noreset = 0;
15986 528504 temp_mapscr->nocarry = 0;
15987 }
15988
15989
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
15990 {
15991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags6),f))
15992 {
15993 return qe_invalid;
15994 }
15995 657968 }
15996
15997
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>5)
15998 {
15999
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags7),f))
16000 {
16001 return qe_invalid;
16002 }
16003
16004
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags8),f))
16005 {
16006 return qe_invalid;
16007 }
16008
16009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags9),f))
16010 {
16011 return qe_invalid;
16012 }
16013
16014
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags10),f))
16015 {
16016 return qe_invalid;
16017 }
16018
16019
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->csensitive),f))
16020 {
16021 return qe_invalid;
16022 }
16023 657968 }
16024 else
16025 {
16026 528504 temp_mapscr->csensitive=1;
16027 }
16028
16029
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version<14) // August 2007: screen SFX added
16030 {
16031
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16032 {
16033 994 temp_mapscr->bosssfx=
16034
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16035 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16036 WAV_ROAR;
16037 994 }
16038
16039
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16040 {
16041 170 temp_mapscr->oceansfx=WAV_SEA;
16042 170 }
16043
16044 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16045 ? 0 : WAV_SECRET;
16046
16047 528504 temp_mapscr->flags3 &= ~66; //64|2
16048 528504 temp_mapscr->flags2 &= ~32;
16049 528504 temp_mapscr->flags &= ~136; // 128|8
16050 528504 }
16051 else
16052 {
16053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->oceansfx),f))
16054 {
16055 return qe_invalid;
16056 }
16057
16058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->bosssfx),f))
16059 {
16060 return qe_invalid;
16061 }
16062
16063
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->secretsfx),f))
16064 {
16065 return qe_invalid;
16066 }
16067 }
16068
16069
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version<15) // October 2007: another SFX
16070 {
16071 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16072 528504 }
16073 else
16074 {
16075
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16076 {
16077 return qe_invalid;
16078 }
16079 }
16080
16081
16082
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16083 {
16084
2/2
✓ Branch 0 taken 6985776 times.
✓ Branch 1 taken 1164296 times.
8150072 for(int32_t k=0; k<6; k++)
16085 {
16086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16087 {
16088 return qe_invalid;
16089 }
16090 6985776 }
16091
16092
2/2
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 6985776 times.
8150072 for(int32_t k=0; k<6; k++)
16093 {
16094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16095 {
16096 return qe_invalid;
16097 }
16098 6985776 }
16099 1164296 }
16100
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16101 {
16102 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16103 {
16104 return qe_invalid;
16105 }
16106
16107 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16108 {
16109 return qe_invalid;
16110 }
16111
16112 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16113 {
16114 return qe_invalid;
16115 }
16116
16117 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16118
16119 {
16120 return qe_invalid;
16121 }
16122 }
16123
16124
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>149))
16125 {
16126
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16127 {
16128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16129 {
16130 return qe_invalid;
16131 }
16132 16320 }
16133
16134
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16135 {
16136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16137 {
16138 return qe_invalid;
16139 }
16140 16320 }
16141
16142
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16143 {
16144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16145 {
16146 return qe_invalid;
16147 }
16148 16320 }
16149
16150
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16151 {
16152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16153 {
16154 return qe_invalid;
16155 }
16156 16320 }
16157
16158
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16159 {
16160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16161 {
16162 return qe_invalid;
16163 }
16164 16320 }
16165
16166
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16167 {
16168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16169 {
16170 return qe_invalid;
16171 }
16172 16320 }
16173 2720 }
16174
16175
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16176 {
16177
2/2
✓ Branch 0 taken 6985776 times.
✓ Branch 1 taken 1164296 times.
8150072 for(int32_t k=0; k<6; k++)
16178 {
16179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16180 {
16181 return qe_invalid;
16182 }
16183 6985776 }
16184 1164296 }
16185
16186
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16187 {
16188
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 if((Header->zelda_version == 0x192)&&(Header->build>153))
16189 {
16190
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16191 {
16192 return qe_invalid;
16193 }
16194 2720 }
16195
16196
1/2
✓ Branch 0 taken 1164296 times.
✗ Branch 1 not taken.
1164296 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16197 {
16198 return qe_invalid;
16199 }
16200 1164296 }
16201
16202
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16203 {
16204 22176 extras=15;
16205 22176 }
16206
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16207 {
16208 extras=11;
16209 }
16210
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16211 {
16212 extras=32;
16213 }
16214
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16215 {
16216 extras=64;
16217 }
16218
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
1164296 else if(Header->zelda_version < 0x193)
16219 {
16220 2720 extras=62;
16221 2720 }
16222 else
16223
16224 {
16225 1161576 extras=0;
16226 }
16227
16228
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1186472 times.
1687752 for(int32_t k=0; k<extras; k++)
16229 {
16230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16231 {
16232 return qe_invalid;
16233 }
16234 501280 }
16235
16236
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16237 //if (version>3)
16238 {
16239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->nextmap),f))
16240 {
16241 return qe_invalid;
16242 }
16243
16244
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->nextscr),f))
16245 {
16246 return qe_invalid;
16247 }
16248 657968 }
16249 else
16250 {
16251 528504 temp_mapscr->nextmap=0;
16252 528504 temp_mapscr->nextscr=0;
16253 }
16254
16255
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16256 {
16257 22176 secretcombos=20;
16258 22176 }
16259
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16260 {
16261 secretcombos=256;
16262 }
16263 else
16264 {
16265 1164296 secretcombos=128;
16266 }
16267
16268
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16269 {
16270
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16271 {
16272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16273 {
16274 return qe_invalid;
16275 }
16276
16277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16278 {
16279 443520 temp_mapscr->secretcombo[k]=tempbyte;
16280 443520 }
16281 443520 }
16282 22176 }
16283 else
16284 {
16285
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16286 {
16287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16288 {
16289 return qe_invalid;
16290 }
16291
16292 149029888 }
16293 }
16294
16295
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16296 {
16297
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16298 {
16299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16300 {
16301 return qe_invalid;
16302 }
16303 149029888 }
16304
16305
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16306 {
16307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16308 {
16309 return qe_invalid;
16310 }
16311 149029888 }
16312 1164296 }
16313
16314
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16315 {
16316 if(!p_getc(&padding,f))
16317 {
16318 return qe_invalid;
16319 }
16320 }
16321
16322
2/2
✓ Branch 0 taken 208819072 times.
✓ Branch 1 taken 1186472 times.
210005544 for(int32_t k=0; k<176; k++)
16323 {
16324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208819072 times.
208819072 if(!p_igetw(&(temp_mapscr->data[k]),f))
16325 {
16326 return qe_invalid;
16327 }
16328 208819072 }
16329
16330
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16331 {
16332 if(!p_getc(&padding,f))
16333 {
16334 return qe_invalid;
16335 }
16336
16337 if(!p_getc(&padding,f))
16338 {
16339 return qe_invalid;
16340 }
16341 }
16342
16343
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16344 {
16345
2/2
✓ Branch 0 taken 204916096 times.
✓ Branch 1 taken 1164296 times.
206080392 for(int32_t k=0; k<176; k++)
16346 {
16347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204916096 times.
204916096 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16348 {
16349 return qe_invalid;
16350 }
16351
16352
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 204437376 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
204916096 if((Header->zelda_version == 0x192)&&(Header->build<24))
16353 {
16354 if(!p_getc(&tempbyte,f))
16355 {
16356 return qe_invalid;
16357 }
16358
16359 if(!p_getc(&tempbyte,f))
16360 {
16361 return qe_invalid;
16362 }
16363
16364 if(!p_getc(&tempbyte,f))
16365 {
16366 return qe_invalid;
16367 }
16368 }
16369 204916096 }
16370 1164296 }
16371
16372
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16373 {
16374
2/2
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 204916096 times.
206080392 for(int32_t k=0; k<176; k++)
16375 {
16376
16377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204916096 times.
204916096 if(!p_getc(&(temp_mapscr->cset[k]),f))
16378 {
16379 return qe_invalid;
16380 }
16381 204916096 }
16382 1164296 }
16383
16384
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16385 {
16386 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16387 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_pages[scrind]<<8);
16388 22176 }
16389
16390
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16391 {
16392 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16393 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16394 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16395 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16396 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16397 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16398 22176 }
16399
16400
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16401 {
16402
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16403 {
16404
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16405 {
16406 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16407 {
16408 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16409 }
16410 }
16411 else
16412 {
16413
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16414 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16415 {
16416 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16417 3902976 }
16418
16419 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16420 }
16421
16422 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_pages[scrind]<<8);
16423 3902976 }
16424 22176 }
16425
16426 /*if(version>12)
16427 {
16428 if(!p_getc(&(temp_mapscr->scrWidth),f))
16429 {
16430 return qe_invalid;
16431 }
16432 if(!p_getc(&(temp_mapscr->scrHeight),f))
16433 {
16434 return qe_invalid;
16435 }
16436 }*/
16437
16438
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>4)
16439 {
16440
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16441 {
16442 return qe_invalid;
16443 }
16444 657968 }
16445 else
16446 {
16447 528504 temp_mapscr->screen_midi = -1;
16448 }
16449
16450
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>=17)
16451 {
16452
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->lens_layer),f))
16453 {
16454 return qe_invalid;
16455 }
16456 657968 }
16457 else
16458 {
16459 528504 temp_mapscr->lens_layer = llNORMAL;
16460 }
16461
16462
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version>6)
16463 {
16464 dword bits;
16465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_igetl(&bits,f))
16466 {
16467 return qe_invalid;
16468 }
16469
16470 int32_t m;
16471 float tempfloat;
16472 word tempw;
16473 657968 temp_mapscr->ffcCountMarkDirty();
16474 657968 temp_mapscr->ffcs.clear();
16475 657968 temp_mapscr->resizeFFC(std::bit_width(bits));
16476
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 21054976 times.
21712944 for(m=0; m<32; m++)
16477 {
16478
2/2
✓ Branch 0 taken 20778977 times.
✓ Branch 1 taken 275999 times.
21054976 if((bits>>m)&1)
16479 {
16480 275999 ffcdata& tempffc = temp_mapscr->ffcs[m];
16481
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(!p_igetw(&tempw,f))
16482 {
16483 return qe_invalid;
16484 }
16485 275999 tempffc.data = tempw;
16486
16487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempffc.cset),f))
16488 {
16489 return qe_invalid;
16490 }
16491
16492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetw(&(tempffc.delay),f))
16493 {
16494 return qe_invalid;
16495 }
16496
16497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(version < 9)
16498 {
16499 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16500 {
16501 return qe_invalid;
16502 }
16503
16504 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16505
16506 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16507 {
16508 return qe_invalid;
16509 }
16510
16511 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16512
16513 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16514 {
16515 return qe_invalid;
16516 }
16517
16518 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16519
16520 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16521 {
16522 return qe_invalid;
16523 }
16524
16525 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16526
16527 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16528 {
16529 return qe_invalid;
16530 }
16531
16532 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16533
16534 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16535 {
16536 return qe_invalid;
16537 }
16538
16539 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16540 }
16541 else
16542 {
16543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.x),f))
16544 {
16545 return qe_invalid;
16546 }
16547
16548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.y),f))
16549 {
16550 return qe_invalid;
16551 }
16552
16553
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(!p_igetzf(&(tempffc.vx),f))
16554 {
16555 return qe_invalid;
16556 }
16557
16558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.vy),f))
16559 {
16560 return qe_invalid;
16561 }
16562
16563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.ax),f))
16564 {
16565 return qe_invalid;
16566 }
16567
16568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.ay),f))
16569 {
16570 return qe_invalid;
16571 }
16572 }
16573
16574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempffc.link),f))
16575 {
16576 return qe_invalid;
16577 }
16578
16579
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version>7)
16580 {
16581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&tempbyte,f))
16582 {
16583 return qe_invalid;
16584 }
16585
16586 275999 tempffc.hit_width = (tempbyte&0x3F)+1;
16587 275999 tempffc.txsz = (tempbyte>>6)+1;
16588
16589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&tempbyte,f))
16590 {
16591 return qe_invalid;
16592 }
16593
16594 275999 tempffc.hit_height = (tempbyte&0x3F)+1;
16595 275999 tempffc.tysz = (tempbyte>>6)+1;
16596
16597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.flags),f))
16598 {
16599 return qe_invalid;
16600 }
16601 275999 }
16602 else
16603 {
16604 tempffc.hit_width=16;
16605 tempffc.hit_height=16;
16606 tempffc.txsz=1;
16607 tempffc.tysz=1;
16608 tempffc.flags=ffc_none;
16609 }
16610
16611 275999 tempffc.updateSolid();
16612
16613
16614
4/6
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269995 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 269995 times.
275999 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16615 {
16616 tempffc.flags|=ffc_ignoreholdup;
16617 }
16618
16619
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version>9)
16620 {
16621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetw(&(tempffc.script),f))
16622 {
16623 return qe_invalid;
16624 }
16625 275999 }
16626 else
16627 {
16628 tempffc.script=0;
16629 }
16630
16631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(version>10)
16632 {
16633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[0]),f))
16634 {
16635 return qe_invalid;
16636 }
16637
16638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[1]),f))
16639 {
16640 return qe_invalid;
16641 }
16642
16643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[2]),f))
16644 {
16645 return qe_invalid;
16646 }
16647
16648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[3]),f))
16649 {
16650 return qe_invalid;
16651 }
16652
16653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[4]),f))
16654 {
16655 return qe_invalid;
16656 }
16657
16658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[5]),f))
16659 {
16660 return qe_invalid;
16661 }
16662
16663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[6]),f))
16664 {
16665 return qe_invalid;
16666 }
16667
16668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[7]),f))
16669 {
16670 return qe_invalid;
16671 }
16672
16673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempbyte),f))
16674 {
16675 return qe_invalid;
16676 }
16677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempbyte),f))
16678 {
16679 return qe_invalid;
16680 }
16681 275999 }
16682
16683
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16684 {
16685 tempffc.script = 0;
16686 for(int q = 0; q < 8; ++q)
16687 tempffc.initd[q] = 0;
16688 }
16689
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version <= 11)
16690 {
16691 fixffcs=true;
16692 }
16693 275999 }
16694 21054976 }
16695
16696 657968 temp_mapscr->shinkToFitFFCs();
16697 657968 }
16698
16699
16700 //add in the new whistle flags
16701
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version<13)
16702 {
16703
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16704 {
16705 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16706 124 }
16707 528504 }
16708
16709 //2.55 starts here
16710
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 19 && Header->zelda_version > 0x253 )
16711 {
16712 // mapscr fields that were never used, so are now removed:
16713 // int32_t npcstrings[10];
16714 // int16_t new_items[10];
16715 // int16_t new_item_x[10];
16716 // int16_t new_item_y[10];
16717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
16718 {
16719 return qe_invalid;
16720 }
16721 34408 }
16722
16723
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 20 && Header->zelda_version > 0x253 )
16724 {
16725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16726 {
16727 return qe_invalid;
16728 }
16729
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16730 {
16731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16732 {
16733 return qe_invalid;
16734 }
16735 275264 }
16736 34408 }
16737
2/2
✓ Branch 0 taken 1152064 times.
✓ Branch 1 taken 34408 times.
1186472 if ( version < 20 )
16738 {
16739 1152064 temp_mapscr->script = 0;
16740
2/2
✓ Branch 0 taken 9216512 times.
✓ Branch 1 taken 1152064 times.
10368576 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16741 1152064 }
16742
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 21 && Header->zelda_version > 0x253 )
16743 {
16744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16745 {
16746 return qe_invalid;
16747 }
16748 34408 }
16749
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
1186472 if ( version < 21 )
16750 {
16751 1152064 temp_mapscr->preloadscript = 0;
16752 1152064 }
16753
16754
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16755 {
16756
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16757 {
16758 return qe_invalid;
16759 }
16760
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16761 {
16762 return qe_invalid;
16763 }
16764 34408 }
16765
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
1186472 if ( version < 22 )
16766 {
16767 1152064 temp_mapscr->hidelayers = 0;
16768 1152064 temp_mapscr->hidescriptlayers = 0;
16769 1152064 }
16770
16771 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16772 //May be any version before 2.11. -Z
16773 /* --not the roar, the HIT SFX
16774 if ( Header->zelda_version <= 0x210 )
16775 {
16776 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16777 {
16778 temp_mapscr->bosssfx = WAV_ROAR;
16779 }
16780 }
16781 */
16782
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
16783 {
16784
1/2
✓ Branch 0 taken 4745888 times.
✗ Branch 1 not taken.
4745888 if(temp_mapscr->door[k] == dNONE)
16785 temp_mapscr->door[k] = dWALL;
16786 4745888 }
16787
16788 1186472 return 0;
16789 1186472 }
16790 1385440 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16791 {
16792
2/2
✓ Branch 0 taken 1186472 times.
✓ Branch 1 taken 198968 times.
1385440 if(version < 23)
16793 {
16794 1186472 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind);
16795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(ret) return ret;
16796 1186472 }
16797 else
16798 {
16799
1/2
✓ Branch 0 taken 198968 times.
✗ Branch 1 not taken.
198968 if(!p_getc(&(temp_mapscr->valid),f))
16800 return qe_invalid;
16801
2/2
✓ Branch 0 taken 105490 times.
✓ Branch 1 taken 93478 times.
198968 if(!(temp_mapscr->valid & mVALID))
16802 {
16803 93478 int map = scrind/MAPSCRS;
16804 93478 int screen = scrind%MAPSCRS;
16805
4/6
✓ Branch 0 taken 86376 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 86376 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 86376 times.
93478 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16806 {
16807 //Empty screen, apply autolayers
16808
2/2
✓ Branch 0 taken 518256 times.
✓ Branch 1 taken 86376 times.
604632 for(int q = 0; q < 6; ++q)
16809 {
16810 518256 auto layermap = map_autolayers[map*6+q];
16811 518256 temp_mapscr->layermap[q] = layermap;
16812
2/2
✓ Branch 0 taken 503100 times.
✓ Branch 1 taken 15156 times.
518256 if(layermap)
16813 15156 temp_mapscr->layerscreen[q] = screen;
16814 518256 }
16815 86376 }
16816 93478 return 0;
16817 }
16818 uint32_t scr_has_flags;
16819
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_igetl(&scr_has_flags,f))
16820 return qe_invalid;
16821
16822
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 95032 times.
105490 if(scr_has_flags & SCRHAS_ROOMDATA)
16823 {
16824
1/2
✓ Branch 0 taken 95032 times.
✗ Branch 1 not taken.
95032 if(!p_getc(&(temp_mapscr->guy),f))
16825 return qe_invalid;
16826
2/2
✓ Branch 0 taken 94912 times.
✓ Branch 1 taken 120 times.
95032 if(version > 26)
16827 {
16828
1/2
✓ Branch 0 taken 94912 times.
✗ Branch 1 not taken.
94912 if(!p_igetl(&(temp_mapscr->guytile),f))
16829 return qe_invalid;
16830
1/2
✓ Branch 0 taken 94912 times.
✗ Branch 1 not taken.
94912 if(!p_getc(&(temp_mapscr->guycs),f))
16831 return qe_invalid;
16832
1/2
✓ Branch 0 taken 94912 times.
✗ Branch 1 not taken.
94912 if(!p_igetw(&(temp_mapscr->roomflags),f))
16833 return qe_invalid;
16834 94912 }
16835 else
16836 {
16837 120 temp_mapscr->guytile = -1; //signal to use default guy values
16838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16839
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16840 }
16841
1/2
✓ Branch 0 taken 95032 times.
✗ Branch 1 not taken.
95032 if(!p_igetw(&(temp_mapscr->str),f))
16842 return qe_invalid;
16843
1/2
✓ Branch 0 taken 95032 times.
✗ Branch 1 not taken.
95032 if(!p_getc(&(temp_mapscr->room),f))
16844 return qe_invalid;
16845
1/2
✓ Branch 0 taken 95032 times.
✗ Branch 1 not taken.
95032 if(!p_igetw(&(temp_mapscr->catchall),f))
16846 return qe_invalid;
16847 95032 }
16848
2/2
✓ Branch 0 taken 103148 times.
✓ Branch 1 taken 2342 times.
105490 if(scr_has_flags & SCRHAS_ITEM)
16849 {
16850
1/2
✓ Branch 0 taken 2342 times.
✗ Branch 1 not taken.
2342 if(!p_getc(&(temp_mapscr->item),f))
16851 return qe_invalid;
16852
1/2
✓ Branch 0 taken 2342 times.
✗ Branch 1 not taken.
2342 if(!p_getc(&(temp_mapscr->hasitem),f))
16853 return qe_invalid;
16854
1/2
✓ Branch 0 taken 2342 times.
✗ Branch 1 not taken.
2342 if(!p_getc(&(temp_mapscr->itemx),f))
16855 return qe_invalid;
16856
1/2
✓ Branch 0 taken 2342 times.
✗ Branch 1 not taken.
2342 if(!p_getc(&(temp_mapscr->itemy),f))
16857 return qe_invalid;
16858 2342 }
16859
2/2
✓ Branch 0 taken 94855 times.
✓ Branch 1 taken 10635 times.
105490 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16860 {
16861
1/2
✓ Branch 0 taken 10635 times.
✗ Branch 1 not taken.
10635 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16862 return qe_invalid;
16863 10635 }
16864
2/2
✓ Branch 0 taken 103020 times.
✓ Branch 1 taken 2470 times.
105490 if(scr_has_flags & SCRHAS_TWARP)
16865 {
16866
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 2470 times.
12350 for(int32_t i=0; i<4; i++)
16867 {
16868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9880 times.
9880 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16869 return qe_invalid;
16870 9880 }
16871
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 2470 times.
12350 for(int32_t i=0; i<4; i++)
16872 {
16873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9880 times.
9880 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16874 return qe_invalid;
16875 9880 }
16876
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 2470 times.
12350 for(int32_t i=0; i<4; i++)
16877 {
16878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9880 times.
9880 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16879 return qe_invalid;
16880 9880 }
16881
1/2
✓ Branch 0 taken 2470 times.
✗ Branch 1 not taken.
2470 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16882 return qe_invalid;
16883 2470 }
16884
2/2
✓ Branch 0 taken 96851 times.
✓ Branch 1 taken 8639 times.
105490 if(scr_has_flags & SCRHAS_SWARP)
16885 {
16886
2/2
✓ Branch 0 taken 34556 times.
✓ Branch 1 taken 8639 times.
43195 for(int32_t i=0; i<4; i++)
16887 {
16888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34556 times.
34556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16889 return qe_invalid;
16890 34556 }
16891
2/2
✓ Branch 0 taken 34556 times.
✓ Branch 1 taken 8639 times.
43195 for(int32_t i=0; i<4; i++)
16892 {
16893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34556 times.
34556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16894 return qe_invalid;
16895 34556 }
16896
2/2
✓ Branch 0 taken 34556 times.
✓ Branch 1 taken 8639 times.
43195 for(int32_t i=0; i<4; i++)
16897 {
16898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34556 times.
34556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16899 return qe_invalid;
16900 34556 }
16901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8639 times.
8639 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16902 return qe_invalid;
16903
1/2
✓ Branch 0 taken 8639 times.
✗ Branch 1 not taken.
8639 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16904 return qe_invalid;
16905 8639 }
16906
2/2
✓ Branch 0 taken 98992 times.
✓ Branch 1 taken 6498 times.
105490 if(scr_has_flags & SCRHAS_WARPRET)
16907 {
16908
2/2
✓ Branch 0 taken 25992 times.
✓ Branch 1 taken 6498 times.
32490 for(int32_t i=0; i<4; i++)
16909 {
16910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25992 times.
25992 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16911 return qe_invalid;
16912 25992 }
16913
2/2
✓ Branch 0 taken 25992 times.
✓ Branch 1 taken 6498 times.
32490 for(int32_t i=0; i<4; i++)
16914 {
16915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25992 times.
25992 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16916 return qe_invalid;
16917 25992 }
16918
1/2
✓ Branch 0 taken 6498 times.
✗ Branch 1 not taken.
6498 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16919 return qe_invalid;
16920
1/2
✓ Branch 0 taken 6498 times.
✗ Branch 1 not taken.
6498 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16921 return qe_invalid;
16922 6498 }
16923
2/2
✓ Branch 0 taken 92003 times.
✓ Branch 1 taken 13487 times.
105490 if(scr_has_flags & SCRHAS_LAYERS)
16924 {
16925
2/2
✓ Branch 0 taken 80922 times.
✓ Branch 1 taken 13487 times.
94409 for(int32_t k=0; k<6; k++)
16926 {
16927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80922 times.
80922 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16928 return qe_invalid;
16929 80922 }
16930
2/2
✓ Branch 0 taken 80922 times.
✓ Branch 1 taken 13487 times.
94409 for(int32_t k=0; k<6; k++)
16931 {
16932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80922 times.
80922 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16933 return qe_invalid;
16934 80922 }
16935
2/2
✓ Branch 0 taken 80922 times.
✓ Branch 1 taken 13487 times.
94409 for(int32_t k=0; k<6; k++)
16936 {
16937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80922 times.
80922 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16938 return qe_invalid;
16939 80922 }
16940
1/2
✓ Branch 0 taken 13487 times.
✗ Branch 1 not taken.
13487 if(!p_getc(&(temp_mapscr->hidelayers),f))
16941 return qe_invalid;
16942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13487 times.
13487 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16943 return qe_invalid;
16944 13487 }
16945
2/2
✓ Branch 0 taken 105386 times.
✓ Branch 1 taken 104 times.
105490 if(scr_has_flags & SCRHAS_MAZE)
16946 {
16947
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
16948 {
16949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->path[k]),f))
16950 return qe_invalid;
16951 416 }
16952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&(temp_mapscr->exitdir),f))
16953 return qe_invalid;
16954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (version >= 32)
16955 {
16956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
16957 return qe_invalid;
16958 104 }
16959 104 }
16960
2/2
✓ Branch 0 taken 76984 times.
✓ Branch 1 taken 28506 times.
105490 if(scr_has_flags & SCRHAS_D_S_U)
16961 {
16962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76984 times.
76984 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16963 return qe_invalid;
16964
2/2
✓ Branch 0 taken 307936 times.
✓ Branch 1 taken 76984 times.
384920 for(int32_t k=0; k<4; k++)
16965 {
16966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 307936 times.
307936 if(!p_getc(&(temp_mapscr->door[k]),f))
16967 return qe_invalid;
16968
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 307576 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
307936 if(version < 29 && temp_mapscr->door[k] == dNONE)
16969 temp_mapscr->door[k] = dWALL;
16970 307936 }
16971
16972
1/2
✓ Branch 0 taken 76984 times.
✗ Branch 1 not taken.
76984 if(!p_getc(&(temp_mapscr->stairx),f))
16973 return qe_invalid;
16974
16975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76984 times.
76984 if(!p_getc(&(temp_mapscr->stairy),f))
16976 return qe_invalid;
16977
1/2
✓ Branch 0 taken 76984 times.
✗ Branch 1 not taken.
76984 if(!p_igetw(&(temp_mapscr->undercombo),f))
16978 return qe_invalid;
16979
1/2
✓ Branch 0 taken 76984 times.
✗ Branch 1 not taken.
76984 if(!p_getc(&(temp_mapscr->undercset),f))
16980 return qe_invalid;
16981 76984 }
16982
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 18018 times.
28506 else if(version < 29)
16983 {
16984
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
16985 41952 temp_mapscr->door[k] = dWALL;
16986 10488 }
16987
2/2
✓ Branch 0 taken 99059 times.
✓ Branch 1 taken 6431 times.
105490 if(scr_has_flags & SCRHAS_FLAGS)
16988 {
16989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6431 times.
6431 if(!p_getc(&(temp_mapscr->flags),f))
16990 return qe_invalid;
16991
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags2),f))
16992 return qe_invalid;
16993
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags3),f))
16994 return qe_invalid;
16995
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags4),f))
16996 return qe_invalid;
16997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6431 times.
6431 if(!p_getc(&(temp_mapscr->flags5),f))
16998 return qe_invalid;
16999
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags6),f))
17000 return qe_invalid;
17001
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags7),f))
17002 return qe_invalid;
17003
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags8),f))
17004 return qe_invalid;
17005
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags9),f))
17006 return qe_invalid;
17007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6431 times.
6431 if(!p_getc(&(temp_mapscr->flags10),f))
17008 return qe_invalid;
17009
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags11),f))
17010 return qe_invalid;
17011 6431 }
17012
2/2
✓ Branch 0 taken 100226 times.
✓ Branch 1 taken 5264 times.
105490 if(scr_has_flags & SCRHAS_ENEMY)
17013 {
17014
2/2
✓ Branch 0 taken 52640 times.
✓ Branch 1 taken 5264 times.
57904 for(int32_t k=0; k<10; k++)
17015 {
17016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52640 times.
52640 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17017 return qe_invalid;
17018
1/2
✓ Branch 0 taken 52640 times.
✗ Branch 1 not taken.
52640 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17019 temp_mapscr->enemy[k] = 0;
17020 52640 }
17021
1/2
✓ Branch 0 taken 5264 times.
✗ Branch 1 not taken.
5264 if(!p_getc(&(temp_mapscr->pattern),f))
17022 return qe_invalid;
17023 5264 }
17024
2/2
✓ Branch 0 taken 105085 times.
✓ Branch 1 taken 405 times.
105490 if(scr_has_flags & SCRHAS_CARRY)
17025 {
17026
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&(temp_mapscr->noreset),f))
17027 return qe_invalid;
17028
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&(temp_mapscr->nocarry),f))
17029 return qe_invalid;
17030
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->nextmap),f))
17031 return qe_invalid;
17032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405 times.
405 if(!p_getc(&(temp_mapscr->nextscr),f))
17033 return qe_invalid;
17034 405 }
17035
2/2
✓ Branch 0 taken 104919 times.
✓ Branch 1 taken 571 times.
105490 if(scr_has_flags & SCRHAS_SCRIPT)
17036 {
17037
1/2
✓ Branch 0 taken 571 times.
✗ Branch 1 not taken.
571 if(!p_igetw(&(temp_mapscr->script),f))
17038 return qe_invalid;
17039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 571 times.
571 if(!p_getc(&(temp_mapscr->preloadscript),f))
17040 return qe_invalid;
17041
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 571 times.
5139 for ( int32_t q = 0; q < 8; q++ )
17042 {
17043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4568 times.
4568 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17044 return qe_invalid;
17045 4568 }
17046 571 }
17047
2/2
✓ Branch 0 taken 74061 times.
✓ Branch 1 taken 31429 times.
105490 if(scr_has_flags & SCRHAS_SECRETS)
17048 {
17049
2/2
✓ Branch 0 taken 4022912 times.
✓ Branch 1 taken 31429 times.
4054341 for(int32_t k=0; k<128; k++)
17050 {
17051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4022912 times.
4022912 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17052 return qe_invalid;
17053 4022912 }
17054
2/2
✓ Branch 0 taken 4022912 times.
✓ Branch 1 taken 31429 times.
4054341 for(int32_t k=0; k<128; k++)
17055 {
17056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4022912 times.
4022912 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17057 return qe_invalid;
17058 4022912 }
17059
2/2
✓ Branch 0 taken 4022912 times.
✓ Branch 1 taken 31429 times.
4054341 for(int32_t k=0; k<128; k++)
17060 {
17061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4022912 times.
4022912 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17062 return qe_invalid;
17063 4022912 }
17064 31429 }
17065
2/2
✓ Branch 0 taken 40658 times.
✓ Branch 1 taken 64832 times.
105490 if(scr_has_flags & SCRHAS_COMBOFLAG)
17066 {
17067
2/2
✓ Branch 0 taken 11410432 times.
✓ Branch 1 taken 64832 times.
11475264 for(int32_t k=0; k<176; ++k)
17068 {
17069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11410432 times.
11410432 if(!p_igetw(&(temp_mapscr->data[k]),f))
17070 return qe_invalid;
17071 11410432 }
17072
2/2
✓ Branch 0 taken 11410432 times.
✓ Branch 1 taken 64832 times.
11475264 for(int32_t k=0; k<176; ++k)
17073 {
17074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11410432 times.
11410432 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17075 return qe_invalid;
17076 11410432 }
17077
2/2
✓ Branch 0 taken 11410432 times.
✓ Branch 1 taken 64832 times.
11475264 for(int32_t k=0; k<176; ++k)
17078 {
17079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11410432 times.
11410432 if(!p_getc(&(temp_mapscr->cset[k]),f))
17080 return qe_invalid;
17081 11410432 }
17082 64832 }
17083
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(scr_has_flags & SCRHAS_MISC)
17084 {
17085
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_igetw(&(temp_mapscr->color),f))
17086 return qe_invalid;
17087
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_getc(&(temp_mapscr->csensitive),f))
17088 return qe_invalid;
17089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105490 times.
105490 if(!p_getc(&(temp_mapscr->oceansfx),f))
17090 return qe_invalid;
17091
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_getc(&(temp_mapscr->bosssfx),f))
17092 return qe_invalid;
17093
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_getc(&(temp_mapscr->secretsfx),f))
17094 return qe_invalid;
17095
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17096 return qe_invalid;
17097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105490 times.
105490 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17098 return qe_invalid;
17099
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17100 return qe_invalid;
17101
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_getc(&(temp_mapscr->lens_layer),f))
17102 return qe_invalid;
17103
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 94912 times.
105490 if(version > 27)
17104 {
17105
1/2
✓ Branch 0 taken 94912 times.
✗ Branch 1 not taken.
94912 if(!p_getc(&(temp_mapscr->lens_show),f))
17106 return qe_invalid;
17107
1/2
✓ Branch 0 taken 94912 times.
✗ Branch 1 not taken.
94912 if(!p_getc(&(temp_mapscr->lens_hide),f))
17108 return qe_invalid;
17109 94912 }
17110 105490 }
17111 else
17112 {
17113 temp_mapscr->screen_midi = -1;
17114 temp_mapscr->csensitive = 1;
17115 }
17116 //FFC
17117 105490 bool old_ff = version < 25;
17118 105490 dword bits = 0;
17119 105490 word numffc = 32;
17120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105490 times.
105490 if(old_ff)
17121 {
17122 if(!p_igetl(&bits,f))
17123 return qe_invalid;
17124 }
17125 else
17126 {
17127
2/4
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105490 times.
105490 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17128 return qe_invalid;
17129 }
17130
17131 105490 temp_mapscr->ffcCountMarkDirty();
17132 105490 temp_mapscr->ffcs.clear();
17133 105490 temp_mapscr->resizeFFC(numffc);
17134
17135 byte tempbyte;
17136 word tempw;
17137
4/6
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 105339 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 151 times.
105490 static ffcdata nil_ffc;
17138
2/2
✓ Branch 0 taken 1981419 times.
✓ Branch 1 taken 105490 times.
2086909 for(word m = 0; m < numffc; ++m)
17139 {
17140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1981419 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1981419 if(old_ff && !(bits & (1<<m))) continue;
17141
17142
1/2
✓ Branch 0 taken 1981419 times.
✗ Branch 1 not taken.
1981419 ffcdata& tempffc = (m < MAXFFCS)
17143 1981419 ? temp_mapscr->ffcs[m]
17144 : nil_ffc; //sanity
17145
17146
1/2
✓ Branch 0 taken 1981419 times.
✗ Branch 1 not taken.
1981419 if(!p_igetw(&tempw,f))
17147 return qe_invalid;
17148
3/4
✓ Branch 0 taken 1981419 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14009 times.
✓ Branch 3 taken 1967410 times.
1981419 if(!old_ff && !tempw) //empty ffc, nothing more to load
17149 1967410 continue;
17150 14009 tempffc.data = tempw;
17151
17152
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_getc(&(tempffc.cset),f))
17153 return qe_invalid;
17154
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetw(&(tempffc.delay),f))
17155 return qe_invalid;
17156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_igetzf(&(tempffc.x),f))
17157 return qe_invalid;
17158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_igetzf(&(tempffc.y),f))
17159 return qe_invalid;
17160
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetzf(&(tempffc.vx),f))
17161 return qe_invalid;
17162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_igetzf(&(tempffc.vy),f))
17163 return qe_invalid;
17164
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetzf(&(tempffc.ax),f))
17165 return qe_invalid;
17166
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetzf(&(tempffc.ay),f))
17167 return qe_invalid;
17168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_getc(&(tempffc.link),f))
17169 return qe_invalid;
17170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(version < 24)
17171 {
17172 if(!p_getc(&tempbyte,f))
17173 return qe_invalid;
17174 tempffc.hit_width = (tempbyte&0x3F)+1;
17175 tempffc.txsz = (tempbyte>>6)+1;
17176 if(!p_getc(&tempbyte,f))
17177 return qe_invalid;
17178 tempffc.hit_height = (tempbyte&0x3F)+1;
17179 tempffc.tysz = (tempbyte>>6)+1;
17180 }
17181 else
17182 {
17183
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetl(&(tempffc.hit_width),f))
17184 return qe_invalid;
17185
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetl(&(tempffc.hit_height),f))
17186 return qe_invalid;
17187
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_getc(&(tempffc.txsz),f))
17188 return qe_invalid;
17189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_getc(&(tempffc.tysz),f))
17190 return qe_invalid;
17191 }
17192
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetl(&(tempffc.flags),f))
17193 return qe_invalid;
17194 14009 tempffc.updateSolid();
17195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_igetw(&(tempffc.script),f))
17196 return qe_invalid;
17197
2/2
✓ Branch 0 taken 112072 times.
✓ Branch 1 taken 14009 times.
126081 for(auto q = 0; q < 8; ++q)
17198 {
17199
1/2
✓ Branch 0 taken 112072 times.
✗ Branch 1 not taken.
112072 if(!p_igetl(&(tempffc.initd[q]),f))
17200 return qe_invalid;
17201 112072 }
17202
2/2
✓ Branch 0 taken 8011 times.
✓ Branch 1 taken 5998 times.
14009 if(version < 33)
17203 {
17204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17205 return qe_invalid;
17206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17207 return qe_invalid;
17208 8011 }
17209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5998 times.
5998 else if(!p_getc(&(tempffc.layer),f))
17210 return qe_invalid;
17211
17212
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17213 {
17214 tempffc.script = 0;
17215 for(int q = 0; q < 8; ++q)
17216 tempffc.initd[q] = 0;
17217 }
17218 14009 }
17219 //END FFC
17220
2/2
✓ Branch 0 taken 38497 times.
✓ Branch 1 taken 66993 times.
105490 if(version > 29)
17221
1/2
✓ Branch 0 taken 66993 times.
✗ Branch 1 not taken.
66993 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17222 return qe_invalid;
17223 }
17224
17225 1291962 temp_mapscr->shinkToFitFFCs();
17226
17227 1291962 return 0;
17228 1385440 }
17229
17230 470 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17231 {
17232
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 24 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17233 470 int32_t screen=0;
17234
17235 470 word version=0;
17236 dword dummy;
17237 int32_t screens_to_read;
17238
17239 470 mapscr temp_mapscr{};
17240 word temp_map_count;
17241 dword section_size;
17242
17243
5/6
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 446 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
470 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17244 {
17245 18 screens_to_read=MAPSCRS192b136;
17246 18 }
17247 else
17248 {
17249 452 screens_to_read=MAPSCRS;
17250 }
17251
17252
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 24 times.
470 if(Header->zelda_version > 0x192)
17253 {
17254 //section version info
17255
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&version,f))
17256 {
17257 return qe_invalid;
17258 }
17259
17260 446 FFCore.quest_format[vMaps] = version;
17261
17262
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&dummy,f))
17263 {
17264 return qe_invalid;
17265 }
17266
17267 //section size
17268
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&section_size,f))
17269 {
17270 return qe_invalid;
17271 }
17272
17273 //finally... section data
17274
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&temp_map_count,f))
17275 {
17276 return 5;
17277 }
17278 446 }
17279 else
17280 {
17281 24 temp_map_count=map_count;
17282 }
17283
17284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 470 times.
470 if (temp_map_count > MAXMAPS)
17285 {
17286 return qe_invalid;
17287 }
17288
17289
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 1 times.
470 if (!should_skip)
17290 {
17291 469 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17292 469 TheMaps.clear();
17293
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 TheMaps.resize(_mapsSize);
17294 469 old_combo_pages.clear();
17295
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 old_combo_pages.resize(_mapsSize);
17296 469 map_autolayers.clear();
17297
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 map_autolayers.resize(temp_map_count*6);
17298
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 137 times.
469 if(version >= 31)
17299 137 Regions = {};
17300 469 }
17301
17302
4/4
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 10325 times.
✓ Branch 2 taken 10325 times.
✓ Branch 3 taken 470 times.
10795 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17303 {
17304 10325 byte valid=1;
17305
2/2
✓ Branch 0 taken 1596 times.
✓ Branch 1 taken 8729 times.
10325 if(version > 22)
17306 {
17307
2/4
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1596 times.
✗ Branch 3 not taken.
1596 if(!p_getc(&valid,f))
17308 return qe_invalid;
17309 1596 }
17310
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 10192 times.
10325 if(valid)
17311 {
17312
2/2
✓ Branch 0 taken 8859 times.
✓ Branch 1 taken 1333 times.
10192 if (version > 25)
17313 {
17314
2/2
✓ Branch 0 taken 7998 times.
✓ Branch 1 taken 1333 times.
9331 for(int q = 0; q < 6; ++q)
17315 {
17316
2/4
✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7998 times.
✗ Branch 3 not taken.
7998 if(!p_igetw(&map_autolayers[i*6+q],f))
17317 return qe_invalid;
17318 7998 }
17319 1333 }
17320
17321
2/2
✓ Branch 0 taken 9301 times.
✓ Branch 1 taken 891 times.
10192 if (version >= 31)
17322 {
17323 static regions_data tmp_rd;
17324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 891 times.
891 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17325
2/2
✓ Branch 0 taken 7128 times.
✓ Branch 1 taken 891 times.
8019 for(int32_t j=0; j<8; j++)
17326 {
17327
2/2
✓ Branch 0 taken 57024 times.
✓ Branch 1 taken 7128 times.
64152 for(int32_t k=0; k<8; k++)
17328 {
17329
2/4
✓ Branch 0 taken 57024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57024 times.
✗ Branch 3 not taken.
57024 if(!p_getc(&rd.region_ids[j][k],f))
17330 {
17331 return qe_invalid;
17332 }
17333 57024 }
17334 7128 }
17335 891 }
17336 10192 }
17337
2/2
✓ Branch 0 taken 1403528 times.
✓ Branch 1 taken 10325 times.
1413853 for(int32_t j=0; j<screens_to_read; j++)
17338 {
17339 1403528 screen=i*MAPSCRS+j;
17340
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1403256 times.
1403528 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17341 1403528 scr->map = i;
17342 1403528 scr->screen = j;
17343
2/2
✓ Branch 0 taken 1385440 times.
✓ Branch 1 taken 18088 times.
1403528 if(valid)
17344
1/2
✓ Branch 0 taken 1385440 times.
✗ Branch 1 not taken.
1385440 readmapscreen(f, Header, scr, version, screen);
17345
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 else if (!should_skip)
17346
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 clear_screen(scr);
17347 1403528 }
17348
17349
2/2
✓ Branch 0 taken 10323 times.
✓ Branch 1 taken 2 times.
10325 if (should_skip)
17350 2 continue;
17351
17352
5/6
✓ Branch 0 taken 10155 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10137 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10323 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17353 {
17354 168 int32_t index = (i*MAPSCRS+132);
17355
17356
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17357
17358 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17359 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17360 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17361
17362
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17363 {
17364 504 screen=i*MAPSCRS+j;
17365
17366
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17367 504 TheMaps[screen].valid = mVERSION;
17368 504 TheMaps[screen].screen_midi = -1;
17369 504 TheMaps[screen].csensitive = 1;
17370 504 }
17371 168 }
17372
17373
5/6
✓ Branch 0 taken 10155 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10137 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10323 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17374 {
17375
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17376 {
17377 22848 screen=i*MAPSCRS+j;
17378
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17379
17380
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17381 {
17382
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17383
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17384
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17385 2924544 }
17386 22848 }
17387 168 }
17388 10323 }
17389 470 map_count = temp_map_count;
17390 470 return 0;
17391 470 }
17392
17393
17394 9020063 void update_combo(newcombo& cmb, word section_version)
17395 {
17396
2/2
✓ Branch 0 taken 1218517 times.
✓ Branch 1 taken 7801546 times.
9020063 if(section_version < 40)
17397 {
17398
3/3
✓ Branch 0 taken 5168 times.
✓ Branch 1 taken 46100 times.
✓ Branch 2 taken 7750278 times.
7801546 switch(cmb.type)
17399 {
17400 case cWATER: case cSHALLOWWATER:
17401 46100 cmb.attribytes[6] = iwRipples;
17402 46100 break;
17403 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17404 5168 cmb.attribytes[6] = iwTallGrass;
17405 5168 break;
17406 }
17407 7801546 }
17408
2/2
✓ Branch 0 taken 871086 times.
✓ Branch 1 taken 8148977 times.
9020063 if(section_version < 49)
17409 {
17410
4/4
✓ Branch 0 taken 8113766 times.
✓ Branch 1 taken 35211 times.
✓ Branch 2 taken 15697 times.
✓ Branch 3 taken 8098069 times.
8148977 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17411 50908 cmb.sfx_landing = WAV_ZN1SPLASH;
17412 8148977 }
17413 9020063 }
17414 293 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17415 {
17416
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 269 times.
293 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17417
17418
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 292 times.
293 if (!should_skip)
17419 {
17420 292 reset_all_combo_animations();
17421 292 init_combo_classes();
17422 292 }
17423
17424 // combos
17425 293 word combos_used=0;
17426 int32_t dummy;
17427 byte padding;
17428 293 newcombo temp_combo;
17429
17430
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 292 times.
293 if (!should_skip)
17431
2/2
✓ Branch 0 taken 19061760 times.
✓ Branch 1 taken 292 times.
19062052 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17432
1/2
✓ Branch 0 taken 19061760 times.
✗ Branch 1 not taken.
19062052 combobuf[q].clear();
17433
17434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
293 if(version < 0x174)
17435 {
17436 combos_used=1024;
17437 }
17438
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 18 times.
293 else if(version < 0x191)
17439 {
17440 18 combos_used=2048;
17441 18 }
17442 else
17443 {
17444
2/4
✓ Branch 0 taken 275 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275 times.
✗ Branch 3 not taken.
275 if(!p_igetw(&combos_used,f))
17445 {
17446 return qe_invalid;
17447 }
17448 }
17449
17450 //finally... section data
17451
2/2
✓ Branch 0 taken 7666530 times.
✓ Branch 1 taken 293 times.
7666823 for(int32_t i=0; i<combos_used; i++)
17452 {
17453
1/2
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
7666530 temp_combo.clear();
17454
1/2
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
7666530 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
17455
17456
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if ( section_version >= 11 )
17457 {
17458
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17459 {
17460 return qe_invalid;
17461 }
17462 202968 }
17463 else
17464 {
17465
2/4
✓ Branch 0 taken 7463562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7463562 times.
✗ Branch 3 not taken.
7463562 if(!p_igetw(&temp_combo.tile,f))
17466 {
17467 return qe_invalid;
17468 }
17469 }
17470 7666530 temp_combo.o_tile = temp_combo.tile;
17471
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.flip,f))
17472 {
17473 return qe_invalid;
17474 }
17475
17476
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.walk,f))
17477 {
17478 return qe_invalid;
17479 }
17480
17481
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.type,f))
17482 {
17483 return qe_invalid;
17484 }
17485
17486
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.csets,f))
17487 {
17488 return qe_invalid;
17489 }
17490
17491
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7596756 times.
7666530 if(version < 0x193)
17492 {
17493
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17494 return qe_invalid;
17495
17496
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17497 return qe_invalid;
17498
17499
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17500 {
17501
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17502 {
17503 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17504 {
17505 if(!p_getc(&padding,f))
17506 return qe_invalid;
17507 }
17508 }
17509 36864 }
17510 69774 }
17511
2/2
✓ Branch 0 taken 7629666 times.
✓ Branch 1 taken 36864 times.
7666530 if(version >= 0x192)
17512 {
17513
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.frames,f))
17514 return qe_invalid;
17515
17516
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.speed,f))
17517 return qe_invalid;
17518
17519
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_igetw(&temp_combo.nextcombo,f))
17520 return qe_invalid;
17521
17522
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.nextcset,f))
17523 return qe_invalid;
17524
17525 //Base flag
17526
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=3)
17527
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.flag,f))
17528 return qe_invalid;
17529
17530
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=4)
17531 {
17532
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.skipanim,f))
17533 return qe_invalid;
17534
17535
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_igetw(&temp_combo.nexttimer,f))
17536 return qe_invalid;
17537 4741258 }
17538
17539
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=5)
17540
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.skipanimy,f))
17541 return qe_invalid;
17542
17543
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=6)
17544 {
17545
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.animflags,f))
17546 return qe_invalid;
17547
17548
1/2
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
4741258 if(section_version == 6)
17549 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17550 4741258 }
17551
17552
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=8) //combo Attributes[4] and userflags.
17553 {
17554
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17555
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17556 return qe_invalid;
17557
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17558 return qe_invalid;
17559
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17560
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17561 return qe_invalid;
17562 202968 }
17563
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=10) //combo trigger flags
17564 {
17565
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17566
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_trigger.triggerflags[q],f))
17567 return qe_invalid;
17568 202968 }
17569
1/2
✓ Branch 0 taken 7426698 times.
✗ Branch 1 not taken.
7426698 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17570 {
17571 for ( int32_t q = 0; q < 2; q++ )
17572 if(!p_igetl(&temp_trigger.triggerflags[q],f))
17573 return qe_invalid;
17574 }
17575
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version >= 9)
17576
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_trigger.triggerlevel,f))
17577 return qe_invalid;
17578
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version >= 22)
17579
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_trigger.triggerbtn,f))
17580 return qe_invalid;
17581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 24)
17582 {
17583 if(!p_getc(&temp_trigger.triggeritem,f))
17584 return qe_invalid;
17585 if(!p_getc(&temp_trigger.trigtimer,f))
17586 return qe_invalid;
17587 }
17588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 25)
17589 if(!p_getc(&temp_trigger.trigsfx,f))
17590 return qe_invalid;
17591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 27)
17592 if(!p_igetl(&temp_trigger.trigchange,f))
17593 return qe_invalid;
17594
17595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 29)
17596 {
17597 if(!p_igetw(&temp_trigger.trigprox,f))
17598 return qe_invalid;
17599 if(!p_getc(&temp_trigger.trigctr,f))
17600 return qe_invalid;
17601 if(!p_igetl(&temp_trigger.trigctramnt,f))
17602 return qe_invalid;
17603 }
17604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 30)
17605 if(!p_getc(&temp_trigger.triglbeam,f))
17606 return qe_invalid;
17607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 31)
17608 {
17609 if(!p_getc(&temp_trigger.trigcschange,f))
17610 return qe_invalid;
17611 if(!p_igetw(&temp_trigger.spawnitem,f))
17612 return qe_invalid;
17613 if(!p_igetw(&temp_trigger.spawnenemy,f))
17614 return qe_invalid;
17615 if(!p_getc(&temp_trigger.exstate,f))
17616 return qe_invalid;
17617 if(!p_igetl(&temp_trigger.spawnip,f))
17618 return qe_invalid;
17619 if(!p_getc(&temp_trigger.trigcopycat,f))
17620 return qe_invalid;
17621 }
17622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 32)
17623 if(!p_getc(&temp_trigger.trigcooldown,f))
17624 return qe_invalid;
17625
17626
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=12) //combo label
17627 {
17628 char label[12];
17629 202968 label[11] = '\0';
17630
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17631
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17632 return qe_invalid;
17633
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17634 202968 }
17635
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=13) //attribytes[4]
17636
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17637
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17638 202968 return qe_invalid;
17639 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17640 * This fixes a poor implementation of a ->next flag bug thing.
17641 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17642 * there was a version bump a few weeks before a change that broke stuff.
17643 */
17644
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7629666 if (section_version >= 13 && section_version < 21)
17645 {
17646 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17647 }
17648 //combo scripts
17649
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=14)
17650 {
17651
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17652 return qe_invalid;
17653
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17654
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17655 return qe_invalid;
17656 202968 }
17657
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=15)
17658 {
17659
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17660
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17661
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17662
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17663 202968 }
17664
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=17) //attribytes[4]
17665 {
17666
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17667
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17668 return qe_invalid;
17669
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17670
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17671 return qe_invalid;
17672 202968 }
17673
17674
2/2
✓ Branch 0 taken 7596756 times.
✓ Branch 1 taken 32910 times.
7629666 if(version < 0x193)
17675
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17676
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17677 32910 return qe_invalid;
17678 7629666 }
17679
17680 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17681
3/6
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4741258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7666530 if((version < 0x211)||((version == 0x211)&&(build<7)))
17682 {
17683
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17684 {
17685
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17686 {
17687 case 130:
17688 temp_combo.tile = 132;
17689 break;
17690
17691 case 131:
17692 temp_combo.tile = 133;
17693 break;
17694
17695 case 132:
17696 temp_combo.tile = 130;
17697 break;
17698
17699 case 133:
17700 temp_combo.tile = 131;
17701 break;
17702 }
17703 39936 }
17704 2925272 }
17705
17706
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 15)
17707 7463562 temp_combo.o_tile = temp_combo.tile;
17708
17709
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version<18) //upper bits for .walk
17710 7463562 temp_combo.walk |= 0xF0;
17711
17712
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 19)
17713
2/2
✓ Branch 0 taken 29854248 times.
✓ Branch 1 taken 7463562 times.
37317810 for(int32_t q = 0; q < 4; ++q)
17714 37317810 temp_combo.attributes[q] *= 10000L;
17715
17716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 23)
17717 {
17718
2/2
✓ Branch 0 taken 15359 times.
✓ Branch 1 taken 7651171 times.
7666530 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17719 {
17720 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17721 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17722 case cTRIGGERGENERIC: case cCSWITCH:
17723 15359 temp_trigger.triggerflags[0] |= combotriggerCMBTYPEFX;
17724 15359 }
17725 7666530 }
17726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 25)
17727 {
17728
2/2
✓ Branch 0 taken 27600 times.
✓ Branch 1 taken 7638930 times.
7666530 switch(temp_combo.type)
17729 {
17730 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27600 times.
27600 if(!(temp_combo.usrflags & cflag3))
17732 27600 temp_combo.attribytes[3] = WAV_DOOR;
17733 27600 temp_combo.usrflags &= ~cflag3;
17734 27600 break;
17735 }
17736 7666530 }
17737
17738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 26)
17739
2/2
✓ Branch 0 taken 7665388 times.
✓ Branch 1 taken 1142 times.
7667672 if(temp_combo.type == cARMOS)
17740
1/2
✓ Branch 0 taken 1142 times.
✗ Branch 1 not taken.
1142 if(temp_combo.usrflags & cflag1)
17741 temp_combo.usrflags |= cflag3;
17742
17743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 27)
17744 {
17745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(temp_trigger.triggerflags[0] & 0x00040000) //'next'
17746 temp_trigger.trigchange = 1;
17747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 else if(temp_trigger.triggerflags[0] & 0x00080000) //'prev'
17748 temp_trigger.trigchange = -1;
17749 7666530 else temp_trigger.trigchange = 0;
17750 7666530 temp_trigger.triggerflags[0] &= ~(0x00040000|0x00080000);
17751 7666530 }
17752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 28)
17753 {
17754
2/2
✓ Branch 0 taken 15669 times.
✓ Branch 1 taken 7650861 times.
7666530 switch(temp_combo.type)
17755 {
17756 case cLOCKBLOCK: case cLOCKEDCHEST:
17757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15669 times.
15669 if(temp_combo.usrflags & cflag7)
17758 temp_combo.usrflags |= cflag8;
17759 15669 else temp_combo.usrflags &= ~cflag8;
17760 15669 temp_combo.usrflags &= ~cflag7;
17761 15669 break;
17762 }
17763
2/2
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 7665748 times.
7666530 switch(temp_combo.type)
17764 {
17765 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17766 782 temp_combo.attrishorts[2] = -1;
17767 782 temp_combo.usrflags |= cflag7;
17768 782 break;
17769 }
17770 7666530 }
17771
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 20)
17772 {
17773 7463562 temp_combo.genflags = 0;
17774
2/2
✓ Branch 0 taken 144654 times.
✓ Branch 1 taken 7318908 times.
7463562 switch(temp_combo.type)
17775 {
17776 case cPUSH_WAIT: case cPUSH_HEAVY:
17777 case cPUSH_HW: case cL_STATUE:
17778 case cR_STATUE: case cPUSH_HEAVY2:
17779 case cPUSH_HW2: case cPOUND:
17780 case cC_STATUE: case cMIRROR:
17781 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17782 case cMAGICPRISM: case cMAGICPRISM4:
17783 case cMAGICSPONGE: case cEYEBALL_A:
17784 case cEYEBALL_B: case cEYEBALL_4:
17785 case cBUSH: case cFLOWERS:
17786 case cLOCKBLOCK: case cLOCKBLOCK2:
17787 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17788 case cCHEST: case cCHEST2:
17789 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17790 case cBOSSCHEST: case cBOSSCHEST2:
17791 case cBUSHNEXT: case cBUSHTOUCHY:
17792 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17793 case cSIGNPOST: case cCSWITCHBLOCK:
17794 case cTORCH: case cTRIGGERGENERIC:
17795
1/2
✓ Branch 0 taken 144654 times.
✗ Branch 1 not taken.
144654 if(temp_combo.usrflags & cflag16)
17796 {
17797 temp_combo.genflags |= cflag1;
17798 temp_combo.usrflags &= ~cflag16;
17799 }
17800 144654 break;
17801 }
17802 7463562 }
17803
17804
3/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15398 times.
✓ Branch 3 taken 7651132 times.
7666530 if(temp_trigger.is_blank())
17805 7651132 temp_combo.triggers.clear();
17806
17807 7666530 update_combo(temp_combo, section_version);
17808
17809
3/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7651611 times.
✓ Branch 3 taken 14919 times.
7666530 if(i>=start_combo && !should_skip)
17810 {
17811
1/2
✓ Branch 0 taken 7651611 times.
✗ Branch 1 not taken.
7651611 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17812 {
17813 temp_combo.script = 0;
17814 for(int q = 0; q < 8; ++q)
17815 temp_combo.initd[q] = 0;
17816 }
17817
1/2
✓ Branch 0 taken 7651611 times.
✗ Branch 1 not taken.
7651611 combobuf[i] = temp_combo;
17818 7651611 }
17819 7666530 }
17820
17821
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 1 times.
293 if (should_skip)
17822 1 return 0;
17823
17824
5/6
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 269 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
292 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17825 {
17826
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17827 {
17828
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17829 {
17830 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17831 215 }
17832 1501440 }
17833 23 }
17834
17835 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17836
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
292 if(version == 0x210 && get_app_id() != App::zquest)
17837 {
17838
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17839
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
17840 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17841 59 }
17842
17843
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 82 times.
292 if(section_version<7)
17844 {
17845
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17846 {
17847
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
17848 {
17849 case cSLASH:
17850 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
17851 853 break;
17852
17853 case cSLASHITEM:
17854 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17855 791 break;
17856
17857 case cBUSH:
17858 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
17859 603 break;
17860
17861 case cFLOWERS:
17862 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17863 174 break;
17864
17865 case cTALLGRASS:
17866 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17867 531 break;
17868
17869 case cSLASHNEXT:
17870 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17871 break;
17872
17873 case cSLASHNEXTITEM:
17874 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17875 break;
17876
17877 case cBUSHNEXT:
17878 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17879 break;
17880 }
17881 5352960 }
17882 82 }
17883
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 287 times.
292 if (section_version < 16)
17884 {
17885
2/2
✓ Branch 0 taken 18735360 times.
✓ Branch 1 taken 287 times.
18735647 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17886 {
17887
2/2
✓ Branch 0 taken 18706079 times.
✓ Branch 1 taken 29281 times.
18735360 if (combobuf[tmpcounter].type == cWATER)
17888 {
17889 29281 combobuf[tmpcounter].attributes[0] = 40000L;
17890 29281 }
17891 18735360 }
17892 287 }
17893
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17894 {
17895 3 combobuf[0].walk = 0xF0;
17896 3 combobuf[0].type = 0;
17897 3 combobuf[0].flag = 0;
17898 3 }
17899
17900 //Now for the new combo alias reset
17901
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 82 times.
292 if(section_version<2)
17902 {
17903
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17904 {
17905 671744 combo_aliases[j].width = 0;
17906 671744 combo_aliases[j].height = 0;
17907 671744 combo_aliases[j].layermask = 0;
17908
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
17909
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
17910 671744 }
17911 82 }
17912
17913
17914
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 setup_combo_animations();
17915
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 setup_combo_animations2();
17916 292 return 0;
17917 293 }
17918
17919 12054 int32_t readcombo_triggers_loop(PACKFILE* f, word s_version, combo_trigger& temp_trigger)
17920 {
17921
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 4474 times.
12054 if(s_version >= 52)
17922
1/2
✓ Branch 0 taken 4474 times.
✗ Branch 1 not taken.
4474 if(!p_getcstr(&temp_trigger.label,f))
17923 return qe_invalid;
17924
17925 12054 int numtrigs = s_version < 36 ? 3 : 6;
17926
2/2
✓ Branch 0 taken 71466 times.
✓ Branch 1 taken 12054 times.
83520 for ( int32_t q = 0; q < numtrigs; q++ )
17927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71466 times.
71466 if(!p_igetl(&temp_trigger.triggerflags[q],f))
17928 return qe_invalid;
17929
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetl(&temp_trigger.triggerlevel,f))
17930 return qe_invalid;
17931
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.triggerbtn,f))
17932 return qe_invalid;
17933
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.triggeritem,f))
17934 return qe_invalid;
17935
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.trigtimer,f))
17936 return qe_invalid;
17937
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.trigsfx,f))
17938 return qe_invalid;
17939
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetl(&temp_trigger.trigchange,f))
17940 return qe_invalid;
17941
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.trigprox,f))
17942 return qe_invalid;
17943
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.trigctr,f))
17944 return qe_invalid;
17945
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetl(&temp_trigger.trigctramnt,f))
17946 return qe_invalid;
17947
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.triglbeam,f))
17948 return qe_invalid;
17949
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.trigcschange,f))
17950 return qe_invalid;
17951
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.spawnitem,f))
17952 return qe_invalid;
17953
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.spawnenemy,f))
17954 return qe_invalid;
17955
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.exstate,f))
17956 return qe_invalid;
17957
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetl(&temp_trigger.spawnip,f))
17958 return qe_invalid;
17959
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.trigcopycat,f))
17960 return qe_invalid;
17961
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.trigcooldown,f))
17962 return qe_invalid;
17963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12054 times.
12054 if(s_version >= 35)
17964 {
17965
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.prompt_cid,f))
17966 return qe_invalid;
17967
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.prompt_cs,f))
17968 return qe_invalid;
17969
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.prompt_x,f))
17970 return qe_invalid;
17971
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.prompt_y,f))
17972 return qe_invalid;
17973 12054 }
17974
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 11768 times.
12054 if(s_version >= 36)
17975 {
17976
1/2
✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
11768 if(!p_getc(&temp_trigger.trig_lstate,f))
17977 return qe_invalid;
17978
1/2
✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
11768 if(!p_getc(&temp_trigger.trig_gstate,f))
17979 return qe_invalid;
17980
1/2
✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
11768 if(!p_igetl(&temp_trigger.trig_statetime,f))
17981 return qe_invalid;
17982 11768 }
17983
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 11768 times.
12054 if(s_version >= 37)
17984 {
17985
1/2
✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
11768 if(!p_igetw(&temp_trigger.trig_genscr,f))
17986 return qe_invalid;
17987 11768 }
17988
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 11620 times.
12054 if(s_version >= 38)
17989 {
17990
1/2
✓ Branch 0 taken 11620 times.
✗ Branch 1 not taken.
11620 if(!p_getc(&temp_trigger.trig_group,f))
17991 return qe_invalid;
17992
1/2
✓ Branch 0 taken 11620 times.
✗ Branch 1 not taken.
11620 if(!p_igetw(&temp_trigger.trig_group_val,f))
17993 return qe_invalid;
17994 11620 }
17995
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 11584 times.
12054 if(s_version >= 45)
17996 {
17997
1/2
✓ Branch 0 taken 11584 times.
✗ Branch 1 not taken.
11584 if(!p_getc(&temp_trigger.exdoor_dir,f))
17998 return qe_invalid;
17999
1/2
✓ Branch 0 taken 11584 times.
✗ Branch 1 not taken.
11584 if(!p_getc(&temp_trigger.exdoor_ind,f))
18000 return qe_invalid;
18001 11584 }
18002
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 4942 times.
12054 if(s_version >= 46)
18003 {
18004
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_getc(&temp_trigger.trig_levelitems,f))
18005 return qe_invalid;
18006
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trigdmlevel,f))
18007 return qe_invalid;
18008
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(s_version >= 48)
18009 {
18010
2/2
✓ Branch 0 taken 14826 times.
✓ Branch 1 taken 4942 times.
19768 for(int q = 0; q < 3; ++q)
18011
1/2
✓ Branch 0 taken 14826 times.
✗ Branch 1 not taken.
14826 if(!p_igetw(&temp_trigger.trigtint[q],f))
18012 return qe_invalid;
18013 4942 }
18014 else
18015 {
18016 for(int q = 0; q < 3; ++q)
18017 if(!p_getc(&temp_trigger.trigtint[q],f))
18018 return qe_invalid;
18019 for(int q = 0; q < 3; ++q)
18020 {
18021 int v = temp_trigger.trigtint[q];
18022 int va = abs(v);
18023 temp_trigger.trigtint[q] = _rgb_scale_6[va] * sign(v);
18024 }
18025 }
18026
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.triglvlpalette,f))
18027 return qe_invalid;
18028
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trigbosspalette,f))
18029 return qe_invalid;
18030
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trigquaketime,f))
18031 return qe_invalid;
18032
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trigwavytime,f))
18033 return qe_invalid;
18034
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trig_swjinxtime,f))
18035 return qe_invalid;
18036
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trig_itmjinxtime,f))
18037 return qe_invalid;
18038
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trig_stuntime,f))
18039 return qe_invalid;
18040
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trig_bunnytime,f))
18041 return qe_invalid;
18042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4942 times.
4942 if(!p_getc(&temp_trigger.trig_pushtime,f))
18043 return qe_invalid;
18044 4942 }
18045
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 4942 times.
12054 if(s_version >= 47)
18046 {
18047
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if (!p_igetw(&temp_trigger.trig_shieldjinxtime, f))
18048 return qe_invalid;
18049 4942 }
18050 12054 return 0;
18051 12054 }
18052
18053 1353533 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18054 {
18055 byte combo_has_flags;
18056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1353533 times.
1353533 if(!p_getc(&combo_has_flags,f))
18057 return qe_invalid;
18058
18059 1353533 temp_combo.clear();
18060
2/2
✓ Branch 0 taken 713729 times.
✓ Branch 1 taken 639804 times.
1353533 if(combo_has_flags)
18061 {
18062
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 639747 times.
639804 if(combo_has_flags&CHAS_BASIC)
18063 {
18064
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_igetl(&temp_combo.tile,f))
18065 return qe_invalid;
18066 639747 temp_combo.o_tile = temp_combo.tile;
18067
18068
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_getc(&temp_combo.flip,f))
18069 return qe_invalid;
18070
18071
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_getc(&temp_combo.walk,f))
18072 return qe_invalid;
18073
18074
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_getc(&temp_combo.type,f))
18075 return qe_invalid;
18076
18077
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_getc(&temp_combo.flag,f))
18078 return qe_invalid;
18079
18080
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_getc(&temp_combo.csets,f))
18081 return qe_invalid;
18082 639747 }
18083
2/2
✓ Branch 0 taken 636980 times.
✓ Branch 1 taken 2824 times.
639804 if(combo_has_flags&CHAS_SCRIPT)
18084 {
18085
2/2
✓ Branch 0 taken 2794 times.
✓ Branch 1 taken 30 times.
2824 if (s_version>=41)
18086 {
18087 2794 p_getcstr(&temp_combo.label, f);
18088 2794 }
18089 else
18090 {
18091 char label[12];
18092 30 label[11] = '\0';
18093
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
18094
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 if(!p_getc(&label[q],f))
18095 return qe_invalid;
18096 30 temp_combo.label = label;
18097 }
18098
18099
1/2
✓ Branch 0 taken 2824 times.
✗ Branch 1 not taken.
2824 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18100 2824 auto initd_count = s_version >= 43 ? 8 : 2;
18101
2/2
✓ Branch 0 taken 22412 times.
✓ Branch 1 taken 2824 times.
25236 for ( int32_t q = 0; q < initd_count; q++ )
18102
1/2
✓ Branch 0 taken 22412 times.
✗ Branch 1 not taken.
22412 if(!p_igetl(&temp_combo.initd[q],f))
18103 return qe_invalid;
18104 2824 }
18105
2/2
✓ Branch 0 taken 517016 times.
✓ Branch 1 taken 122788 times.
639804 if(combo_has_flags&CHAS_ANIM)
18106 {
18107
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.frames,f))
18108 return qe_invalid;
18109
18110
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.speed,f))
18111 return qe_invalid;
18112
18113
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_igetw(&temp_combo.nextcombo,f))
18114 return qe_invalid;
18115
18116
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.nextcset,f))
18117 return qe_invalid;
18118
18119
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.skipanim,f))
18120 return qe_invalid;
18121
18122
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.skipanimy,f))
18123 return qe_invalid;
18124
18125
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.animflags,f))
18126 return qe_invalid;
18127 122788 }
18128
2/2
✓ Branch 0 taken 587386 times.
✓ Branch 1 taken 52418 times.
639804 if(combo_has_flags&CHAS_ATTRIB)
18129 {
18130
2/2
✓ Branch 0 taken 209672 times.
✓ Branch 1 taken 52418 times.
262090 for ( int32_t q = 0; q < 4; q++ )
18131
1/2
✓ Branch 0 taken 209672 times.
✗ Branch 1 not taken.
209672 if(!p_igetl(&temp_combo.attributes[q],f))
18132 return qe_invalid;
18133
2/2
✓ Branch 0 taken 419344 times.
✓ Branch 1 taken 52418 times.
471762 for ( int32_t q = 0; q < 8; q++ )
18134
1/2
✓ Branch 0 taken 419344 times.
✗ Branch 1 not taken.
419344 if(!p_getc(&temp_combo.attribytes[q],f))
18135 return qe_invalid;
18136
2/2
✓ Branch 0 taken 419344 times.
✓ Branch 1 taken 52418 times.
471762 for ( int32_t q = 0; q < 8; q++ )
18137
1/2
✓ Branch 0 taken 419344 times.
✗ Branch 1 not taken.
419344 if(!p_igetw(&temp_combo.attrishorts[q],f))
18138 return qe_invalid;
18139 52418 }
18140
2/2
✓ Branch 0 taken 628484 times.
✓ Branch 1 taken 11320 times.
639804 if(combo_has_flags&CHAS_FLAG)
18141 {
18142
1/2
✓ Branch 0 taken 11320 times.
✗ Branch 1 not taken.
11320 if(!p_igetl(&temp_combo.usrflags,f))
18143 return qe_invalid;
18144
1/2
✓ Branch 0 taken 11320 times.
✗ Branch 1 not taken.
11320 if(!p_igetw(&temp_combo.genflags,f))
18145 return qe_invalid;
18146 11320 }
18147
2/2
✓ Branch 0 taken 627750 times.
✓ Branch 1 taken 12054 times.
639804 if(combo_has_flags&CHAS_TRIG)
18148 {
18149 12054 byte count = 1;
18150
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 4474 times.
12054 if(s_version >= 52)
18151
1/2
✓ Branch 0 taken 4474 times.
✗ Branch 1 not taken.
4474 if(!p_getc(&count, f))
18152 return qe_invalid;
18153
18154
2/2
✓ Branch 0 taken 12054 times.
✓ Branch 1 taken 12054 times.
24108 for(byte q = 0; q < count; ++q)
18155 {
18156 12054 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
18157 12054 auto ret = readcombo_triggers_loop(f, s_version, temp_trigger);
18158
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(ret)
18159 return ret;
18160 12054 }
18161
18162
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 4474 times.
12054 if(s_version < 52)
18163 {
18164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7580 times.
7580 if(!temp_combo.triggers.empty())
18165 7580 temp_combo.only_gentrig = (temp_combo.triggers[0].triggerflags[0] & combotriggerONLYGENTRIG) ? 1 : 0;
18166 7580 }
18167
1/2
✓ Branch 0 taken 4474 times.
✗ Branch 1 not taken.
4474 else if(!p_getc(&temp_combo.only_gentrig,f))
18168 return qe_invalid;
18169 12054 }
18170
2/2
✓ Branch 0 taken 639291 times.
✓ Branch 1 taken 513 times.
639804 if(combo_has_flags&CHAS_LIFT)
18171 {
18172
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_igetw(&temp_combo.liftcmb,f))
18173 return qe_invalid;
18174
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftcs,f))
18175 return qe_invalid;
18176
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_igetw(&temp_combo.liftundercmb,f))
18177 return qe_invalid;
18178
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftundercs,f))
18179 return qe_invalid;
18180
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftdmg,f))
18181 return qe_invalid;
18182
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftlvl,f))
18183 return qe_invalid;
18184
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftitm,f))
18185 return qe_invalid;
18186
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftflags,f))
18187 return qe_invalid;
18188
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftgfx,f))
18189 return qe_invalid;
18190
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftsprite,f))
18191 return qe_invalid;
18192
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftsfx,f))
18193 return qe_invalid;
18194
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18195 return qe_invalid;
18196
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftbreaksfx,f))
18197 return qe_invalid;
18198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 513 times.
513 if(s_version >= 34)
18199 {
18200
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.lifthei,f))
18201 return qe_invalid;
18202
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.lifttime,f))
18203 return qe_invalid;
18204 513 }
18205
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 499 times.
513 if(s_version >= 39)
18206 {
18207
1/2
✓ Branch 0 taken 499 times.
✗ Branch 1 not taken.
499 if(!p_getc(&temp_combo.lift_parent_item,f))
18208 return qe_invalid;
18209 499 }
18210
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 396 times.
513 if(s_version >= 51)
18211 {
18212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 if(!p_getc(&temp_combo.liftlightrad,f))
18213 return qe_invalid;
18214
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(!p_getc(&temp_combo.liftlightshape,f))
18215 return qe_invalid;
18216 396 }
18217 513 }
18218
2/2
✓ Branch 0 taken 609474 times.
✓ Branch 1 taken 30330 times.
639804 if(combo_has_flags&CHAS_GENERAL)
18219 {
18220
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.speed_mult,f))
18221 return qe_invalid;
18222
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.speed_div,f))
18223 return qe_invalid;
18224
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_igetzf(&temp_combo.speed_add,f))
18225 return qe_invalid;
18226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30330 times.
30330 if(s_version >= 42)
18227 {
18228
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_appear,f))
18229 return qe_invalid;
18230
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_disappear,f))
18231 return qe_invalid;
18232
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_loop,f))
18233 return qe_invalid;
18234
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_walking,f))
18235 return qe_invalid;
18236
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_standing,f))
18237 return qe_invalid;
18238
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.spr_appear,f))
18239 return qe_invalid;
18240
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.spr_disappear,f))
18241 return qe_invalid;
18242
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.spr_walking,f))
18243 return qe_invalid;
18244
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.spr_standing,f))
18245 return qe_invalid;
18246 30330 }
18247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30330 times.
30330 if(s_version >= 44)
18248 {
18249
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_tap,f))
18250 return qe_invalid;
18251 30330 }
18252
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 29964 times.
30330 if(s_version >= 49)
18253 {
18254
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.sfx_landing,f))
18255 return qe_invalid;
18256 29964 }
18257
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 29964 times.
30330 if(s_version >= 50)
18258 {
18259
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.spr_falling,f))
18260 return qe_invalid;
18261
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.spr_drowning,f))
18262 return qe_invalid;
18263
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18264 return qe_invalid;
18265
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.sfx_falling,f))
18266 return qe_invalid;
18267
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.sfx_drowning,f))
18268 return qe_invalid;
18269
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18270 return qe_invalid;
18271 29964 }
18272 30330 }
18273 639804 }
18274 1353533 update_combo(temp_combo, s_version);
18275 1353533 return 0;
18276 1353533 }
18277
18278 470 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18279 {
18280
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 24 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18281
18282 470 word section_version=0;
18283 470 word combos_used=0;
18284 int32_t dummy;
18285 byte padding;
18286 470 newcombo temp_combo;
18287
18288
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 469 times.
470 if (!should_skip)
18289 {
18290
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 reset_all_combo_animations();
18291
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 init_combo_classes();
18292
18293
2/2
✓ Branch 0 taken 30616320 times.
✓ Branch 1 taken 469 times.
30616789 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18294
1/2
✓ Branch 0 taken 30616320 times.
✗ Branch 1 not taken.
30616320 combobuf[q].clear();
18295 469 }
18296
18297
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 24 times.
470 if(version > 0x192) //Version info
18298 {
18299
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&section_version,f))
18300 {
18301 return qe_invalid;
18302 }
18303 446 FFCore.quest_format[vCombos] = section_version;
18304
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!read_deprecated_section_cversion(f))
18305 {
18306 return qe_invalid;
18307 }
18308
18309 //section size
18310
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&dummy,f))
18311 {
18312 return qe_invalid;
18313 }
18314 446 }
18315
18316
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 293 times.
470 if(section_version > 32) //Cleanup time!
18317 {
18318
2/4
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 177 times.
✗ Branch 3 not taken.
177 if(!p_igetw(&combos_used,f))
18319 {
18320 return qe_invalid;
18321 }
18322
2/2
✓ Branch 0 taken 1353533 times.
✓ Branch 1 taken 177 times.
1353710 for(int32_t i=0; i<combos_used; i++)
18323 {
18324
1/2
✓ Branch 0 taken 1353533 times.
✗ Branch 1 not taken.
1353533 auto ret = readcombo_loop(f,section_version,temp_combo);
18325
1/2
✓ Branch 0 taken 1353533 times.
✗ Branch 1 not taken.
1353533 if(ret) return ret;
18326
1/2
✓ Branch 0 taken 1353533 times.
✗ Branch 1 not taken.
1353533 if(i>=start_combo)
18327 {
18328
1/2
✓ Branch 0 taken 1353533 times.
✗ Branch 1 not taken.
1353533 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18329 {
18330 temp_combo.script = 0;
18331 for(int q = 0; q < 8; ++q)
18332 temp_combo.initd[q] = 0;
18333 }
18334
1/2
✓ Branch 0 taken 1353533 times.
✗ Branch 1 not taken.
1353533 combobuf[i] = temp_combo;
18335 1353533 }
18336 1353533 }
18337 177 }
18338 else //Call the old function for all old versions
18339 {
18340
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
293 if(ret) return ret; //error, end read
18342 }
18343
18344
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 1 times.
470 if (should_skip)
18345 1 return 0;
18346
18347
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 168 times.
469 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18348 {
18349 168 combobuf[0].walk = 0xF0;
18350 168 combobuf[0].type = 0;
18351 168 combobuf[0].flag = 0;
18352 168 }
18353
18354
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 setup_combo_animations();
18355
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 setup_combo_animations2();
18356 469 return 0;
18357 470 }
18358
18359 387 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18360 {
18361 //these are here to bypass compiler warnings about unused arguments
18362 387 Header=Header;
18363 387 version=version;
18364 387 build=build;
18365
18366 int32_t dummy;
18367 387 word sversion=0, c_sversion;
18368
18369 //section version info
18370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&sversion,f))
18371 {
18372 return qe_invalid;
18373 }
18374
18375 387 FFCore.quest_format[vComboAliases] = sversion;
18376
18377
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&c_sversion,f))
18378 {
18379 return qe_invalid;
18380 }
18381
18382 //section size
18383
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy,f))
18384 {
18385 return qe_invalid;
18386 }
18387
18388 387 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18389
18390
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18391 {
18392 205 max_num_combo_aliases = MAX250COMBOALIASES;
18393 205 }
18394
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18395 {
18396 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18397 }
18398
18399
2/2
✓ Branch 0 taken 1910784 times.
✓ Branch 1 taken 387 times.
1911171 for(int32_t j=0; j<max_num_combo_aliases; j++)
18400 {
18401 byte width,height,mask,tempcset;
18402 int32_t count;
18403 word tempword;
18404 byte tempbyte;
18405
18406
1/2
✓ Branch 0 taken 1910784 times.
✗ Branch 1 not taken.
1910784 if(!p_igetw(&tempword,f))
18407 {
18408 return qe_invalid;
18409 }
18410
18411 1910784 combo_aliases[j].combo = tempword;
18412
18413
1/2
✓ Branch 0 taken 1910784 times.
✗ Branch 1 not taken.
1910784 if(!p_getc(&tempbyte,f))
18414 {
18415 return qe_invalid;
18416 }
18417
18418 1910784 combo_aliases[j].cset = tempbyte;
18419
18420
1/2
✓ Branch 0 taken 1910784 times.
✗ Branch 1 not taken.
1910784 if(!p_getc(&width,f))
18421 {
18422 return qe_invalid;
18423 }
18424
18425
1/2
✓ Branch 0 taken 1910784 times.
✗ Branch 1 not taken.
1910784 if(!p_getc(&height,f))
18426 {
18427 return qe_invalid;
18428 }
18429
18430
1/2
✓ Branch 0 taken 1910784 times.
✗ Branch 1 not taken.
1910784 if(!p_getc(&mask,f))
18431 {
18432 return qe_invalid;
18433 }
18434
18435 1910784 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18436
18437 1910784 combo_aliases[j].width = width;
18438 1910784 combo_aliases[j].height = height;
18439 1910784 combo_aliases[j].layermask = mask;
18440 1910784 combo_aliases[j].combos.clear();
18441 1910784 combo_aliases[j].csets.clear();
18442
18443
2/2
✓ Branch 0 taken 1961348 times.
✓ Branch 1 taken 1910784 times.
3872132 for(int32_t k=0; k<count; k++)
18444 {
18445
1/2
✓ Branch 0 taken 1961348 times.
✗ Branch 1 not taken.
1961348 if(!p_igetw(&tempword,f))
18446 {
18447 return qe_invalid;
18448 }
18449
18450 1961348 combo_aliases[j].combos[k] = tempword;
18451 1961348 }
18452
18453
2/2
✓ Branch 0 taken 1961348 times.
✓ Branch 1 taken 1910784 times.
3872132 for(int32_t k=0; k<count; k++)
18454 {
18455
1/2
✓ Branch 0 taken 1961348 times.
✗ Branch 1 not taken.
1961348 if(!p_getc(&tempcset,f))
18456 {
18457 return qe_invalid;
18458 }
18459
18460 1961348 combo_aliases[j].csets[k] = tempcset;
18461 1961348 }
18462 1910784 }
18463
18464 //Combo pools!
18465 387 word num_combo_pools = 0;
18466
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 177 times.
387 if(sversion >= 4)
18467 {
18468
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_igetw(&num_combo_pools,f))
18469 {
18470 return qe_invalid;
18471 }
18472 177 }
18473
18474
2/2
✓ Branch 0 taken 3170304 times.
✓ Branch 1 taken 387 times.
3170691 for(combo_pool& pool : combo_pools)
18475 {
18476 3170304 pool.clear();
18477 }
18478
18479 387 combo_pool temp_cpool;
18480
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 387 times.
831 for(word cp = 0; cp < num_combo_pools; ++cp)
18481 {
18482 444 int32_t num_combos_in_pool = 0;
18483
2/4
✓ Branch 0 taken 444 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 444 times.
✗ Branch 3 not taken.
444 if(!p_igetl(&num_combos_in_pool,f))
18484 {
18485 return qe_invalid;
18486 }
18487
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 96 times.
444 if(num_combos_in_pool < 1) continue; //nothing to read
18488
18489
1/2
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
348 temp_cpool.clear();
18490
18491 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18492
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 1576 times.
1924 for(auto q = 0; q < num_combos_in_pool; ++q)
18493 {
18494
2/4
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1576 times.
✗ Branch 3 not taken.
1576 if(!p_igetl(&cp_cid,f))
18495 {
18496 return qe_invalid;
18497 }
18498
2/4
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1576 times.
✗ Branch 3 not taken.
1576 if(!p_getc(&cp_cs,f))
18499 {
18500 return qe_invalid;
18501 }
18502
2/4
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1576 times.
✗ Branch 3 not taken.
1576 if(!p_igetw(&cp_quant,f))
18503 {
18504 return qe_invalid;
18505 }
18506
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18507 1576 }
18508
18509
1/2
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
348 combo_pools[cp] = temp_cpool;
18510 348 }
18511
18512 //Autocombos!
18513 387 word num_combo_autos = 0;
18514
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 222 times.
387 if (sversion >= 5)
18515 {
18516
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if (!p_igetw(&num_combo_autos, f))
18517 {
18518 return qe_invalid;
18519 }
18520 165 }
18521
18522
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 3170304 times.
3170691 for (combo_auto& cauto : combo_autos)
18523 {
18524
1/2
✓ Branch 0 taken 3170304 times.
✗ Branch 1 not taken.
3170304 cauto.clear(true);
18525 }
18526
18527
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 combo_auto temp_cauto;
18528
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 387 times.
462 for (word ca = 0; ca < num_combo_autos; ++ca)
18529 {
18530 byte type;
18531 int32_t display_cid, erase_cid;
18532 byte flags, arg;
18533
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&type, f))
18534 {
18535 return qe_invalid;
18536 }
18537
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&display_cid, f))
18538 {
18539 return qe_invalid;
18540 }
18541
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&erase_cid, f))
18542 {
18543 return qe_invalid;
18544 }
18545
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&flags, f))
18546 {
18547 return qe_invalid;
18548 }
18549
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&arg, f))
18550 {
18551 return qe_invalid;
18552 }
18553 75 int32_t num_combos_in_cauto = 0;
18554
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&num_combos_in_cauto, f))
18555 {
18556 return qe_invalid;
18557 }
18558
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if (num_combos_in_cauto < 1) continue; //nothing to read
18559
18560
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.clear();
18561
18562
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setType(type);
18563
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setDisplay(display_cid);
18564
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setEraseCombo(erase_cid);
18565
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setFlags(flags);
18566
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setArg(arg);
18567
18568 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18569
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 930 times.
1005 for (auto q = 0; q < num_combos_in_cauto; ++q)
18570 {
18571
2/4
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
930 if (!p_getc(&ca_ctype, f))
18572 {
18573 return qe_invalid;
18574 }
18575
2/4
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
930 if (!p_igetl(&ca_cid, f))
18576 {
18577 return qe_invalid;
18578 }
18579
1/2
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
930 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18580 930 }
18581
18582
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 combo_autos[ca] = temp_cauto;
18583 75 }
18584
18585 387 return 0;
18586 387 }
18587
18588 787 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18589 {
18590
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 24 times.
787 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18591
18592 //these are here to bypass compiler warnings about unused arguments
18593 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18594 //Capitalized cause it'll save you a headache. -Deedee
18595 787 start_cset=start_cset;
18596 787 max_csets=max_csets;
18597 787 word s_version=0;
18598
18599 miscQdata temp_misc;
18600 787 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18601
18602 byte temp_colordata[48];
18603 char temp_palname[PALNAMESIZE+1];
18604
18605 int32_t dummy;
18606 word palcycles;
18607
18608
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(version > 0x192)
18609 {
18610 //section version info
18611
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&s_version,f))
18612 {
18613 return qe_invalid;
18614 }
18615
18616 763 FFCore.quest_format[vCSets] = s_version;
18617
18618
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&dummy,f))
18619 {
18620 return qe_invalid;
18621 }
18622
18623 //section size
18624
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetl(&dummy,f))
18625 {
18626 return qe_invalid;
18627 }
18628 763 }
18629
2/2
✓ Branch 0 taken 605 times.
✓ Branch 1 taken 182 times.
787 if (s_version < 5)
18630 {
18631
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 587 times.
✓ Branch 2 taken 581 times.
✓ Branch 3 taken 6 times.
605 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18632
18633 //finally... section data
18634 605 int32_t q = 0;
18635 605 int32_t p = -15;
18636
2/2
✓ Branch 0 taken 145200 times.
✓ Branch 1 taken 605 times.
145805 for(int32_t i=0; i<oldpdTOTAL; ++i)
18637 {
18638 145200 memset(temp_colordata, 0, 48);
18639
18640
1/2
✓ Branch 0 taken 145200 times.
✗ Branch 1 not taken.
145200 if(!pfread(temp_colordata,48,f))
18641 {
18642 return qe_invalid;
18643 }
18644
18645
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 144960 times.
145200 if (should_skip)
18646 240 continue;
18647
18648 144960 memcpy(&colordata[q*48], temp_colordata, 48);
18649
18650 144960 ++q;
18651
8/8
✓ Branch 0 taken 135296 times.
✓ Branch 1 taken 9664 times.
✓ Branch 2 taken 10268 times.
✓ Branch 3 taken 125028 times.
✓ Branch 4 taken 1208 times.
✓ Branch 5 taken 9060 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1172 times.
144960 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18652 {
18653
1/2
✓ Branch 0 taken 10232 times.
✗ Branch 1 not taken.
10232 if (s_version < 5) //Bumping up the size of level palettes
18654 {
18655 10232 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18656 10232 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18657 10232 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18658 10232 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18659 10232 q+=4;
18660 10232 }
18661 else
18662 {
18663 for(int m = 0; m < 4; ++m)
18664 {
18665 memset(temp_colordata, 0, 48);
18666 if(!pfread(temp_colordata,48,f))
18667 {
18668 return qe_invalid;
18669 }
18670 memcpy(&colordata[q*48], temp_colordata, 48);
18671 ++q;
18672 }
18673 }
18674 10232 }
18675 144960 ++p;
18676 144960 }
18677
18678
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 587 times.
605 if(RealOldVerion)
18679 {
18680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18681 {
18682 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18683 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18684 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18685 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18686 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18687 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18688 18 }
18689 18 }
18690 else
18691 {
18692 587 memset(temp_colordata, 0, 48);
18693
18694
2/2
✓ Branch 0 taken 1839071 times.
✓ Branch 1 taken 587 times.
1839658 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18695 {
18696
1/2
✓ Branch 0 taken 1839071 times.
✗ Branch 1 not taken.
1839071 if(!pfread(temp_colordata,48,f))
18697 {
18698 return qe_invalid;
18699 }
18700
18701
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1835938 times.
1839071 if (should_skip)
18702 3133 continue;
18703
18704 1835938 memcpy(&colordata[q*48], temp_colordata, 48);
18705
18706 1835938 ++q;
18707
7/8
✓ Branch 0 taken 1835938 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141226 times.
✓ Branch 3 taken 1694712 times.
✓ Branch 4 taken 1172 times.
✓ Branch 5 taken 140054 times.
✓ Branch 6 taken 1044 times.
✓ Branch 7 taken 128 times.
1835938 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18708 {
18709
1/2
✓ Branch 0 taken 141098 times.
✗ Branch 1 not taken.
141098 if (s_version < 5) //Bumping up the size of level palettes
18710 {
18711 141098 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18712 141098 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18713 141098 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18714 141098 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18715 141098 q+=4;
18716 141098 }
18717 else
18718 {
18719 for(int m = 0; m < 4; ++m)
18720 {
18721 memset(temp_colordata, 0, 48);
18722 if(!pfread(temp_colordata,48,f))
18723 {
18724 return qe_invalid;
18725 }
18726 memcpy(&colordata[q*48], temp_colordata, 48);
18727 ++q;
18728 }
18729 }
18730 141098 }
18731 1835938 ++p;
18732 1835938 }
18733
18734
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 522 times.
587 if(s_version < 4)
18735 {
18736
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
18737 {
18738 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18739 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18740 64 }
18741 65 }
18742 else
18743 {
18744
2/2
✓ Branch 0 taken 1737216 times.
✓ Branch 1 taken 522 times.
1737738 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18745 {
18746
1/2
✓ Branch 0 taken 1737216 times.
✗ Branch 1 not taken.
1737216 if(!pfread(temp_colordata,48,f))
18747 {
18748 return qe_invalid;
18749 }
18750
18751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1737216 times.
1737216 if (should_skip)
18752 continue;
18753
18754 1737216 memcpy(&colordata[q*48], temp_colordata, 48);
18755 1737216 ++q;
18756
5/6
✓ Branch 0 taken 1737216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133632 times.
✓ Branch 3 taken 1603584 times.
✓ Branch 4 taken 1044 times.
✓ Branch 5 taken 132588 times.
1737216 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18757 {
18758
1/2
✓ Branch 0 taken 132588 times.
✗ Branch 1 not taken.
132588 if (s_version < 5) //Bumping up the size of level palettes
18759 {
18760 132588 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18761 132588 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18762 132588 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18763 132588 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18764 132588 q+=4;
18765 132588 }
18766 else
18767 {
18768 for(int m = 0; m < 4; ++m)
18769 {
18770 memset(temp_colordata, 0, 48);
18771 if(!pfread(temp_colordata,48,f))
18772 {
18773 return qe_invalid;
18774 }
18775 memcpy(&colordata[q*48], temp_colordata, 48);
18776 ++q;
18777 }
18778 }
18779 132588 }
18780 1737216 ++p;
18781 1737216 }
18782
18783 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18784 }
18785 }
18786 605 }
18787 else
18788 {
18789
2/2
✓ Branch 0 taken 1592318 times.
✓ Branch 1 taken 182 times.
1592500 for(int32_t i=0; i<pdTOTAL255; ++i)
18790 {
18791 1592318 memset(temp_colordata, 0, 48);
18792
18793
1/2
✓ Branch 0 taken 1592318 times.
✗ Branch 1 not taken.
1592318 if(!pfread(temp_colordata,48,f))
18794 {
18795 return qe_invalid;
18796 }
18797
18798 1592318 memcpy(&colordata[i*48], temp_colordata, 48);
18799 1592318 }
18800 }
18801
18802
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 137 times.
✓ Branch 3 taken 649 times.
787 if (!should_skip && s_version < 6)
18803 {
18804
2/2
✓ Branch 0 taken 272548848 times.
✓ Branch 1 taken 649 times.
272549497 for (int i = 0; i < psTOTAL255; i++)
18805 {
18806 272548848 colordata[i] = _rgb_scale_6[colordata[i]];
18807 272548848 }
18808 649 }
18809
18810
5/6
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 763 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
787 if((version < 0x192)||((version == 0x192)&&(build<76)))
18811 {
18812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18813 18 init_palnames();
18814 18 }
18815 else
18816 {
18817 769 int32_t palnamestoread = 0;
18818
18819
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 704 times.
769 if(s_version < 3)
18820 65 palnamestoread = OLDMAXLEVELS;
18821 else
18822 704 palnamestoread = 512;
18823
18824
2/2
✓ Branch 0 taken 377088 times.
✓ Branch 1 taken 769 times.
377857 for(int32_t i=0; i<palnamestoread; ++i)
18825 {
18826
1/2
✓ Branch 0 taken 377088 times.
✗ Branch 1 not taken.
377088 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18827 {
18828 return qe_invalid;
18829 }
18830
18831
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 376832 times.
377088 if (!should_skip)
18832 376832 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18833 377088 }
18834
18835
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 768 times.
769 if (should_skip)
18836 1 return 0;
18837
18838
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 768 times.
17152 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18839 {
18840 16384 memset(palnames[i], 0, PALNAMESIZE);
18841 16384 }
18842 }
18843
18844
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 763 times.
786 if(version > 0x192)
18845 {
18846
2/2
✓ Branch 0 taken 195328 times.
✓ Branch 1 taken 763 times.
196091 for(int32_t i=0; i<256; i++)
18847 {
18848
2/2
✓ Branch 0 taken 585984 times.
✓ Branch 1 taken 195328 times.
781312 for(int32_t j=0; j<3; j++)
18849 {
18850 585984 temp_misc.cycles[i][j].first=0;
18851 585984 temp_misc.cycles[i][j].count=0;
18852 585984 temp_misc.cycles[i][j].speed=0;
18853 585984 }
18854 195328 }
18855
18856
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&palcycles,f))
18857 {
18858 return qe_invalid;
18859 }
18860
18861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if (palcycles > NUM_PAL_CYCLES)
18862 {
18863 return qe_invalid;
18864 }
18865
18866
2/2
✓ Branch 0 taken 22139 times.
✓ Branch 1 taken 763 times.
22902 for(int32_t i=0; i<palcycles; i++)
18867 {
18868
2/2
✓ Branch 0 taken 66417 times.
✓ Branch 1 taken 22139 times.
88556 for(int32_t j=0; j<3; j++)
18869 {
18870
1/2
✓ Branch 0 taken 66417 times.
✗ Branch 1 not taken.
66417 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18871 {
18872 return qe_invalid;
18873 }
18874 66417 }
18875
18876
2/2
✓ Branch 0 taken 66417 times.
✓ Branch 1 taken 22139 times.
88556 for(int32_t j=0; j<3; j++)
18877 {
18878
1/2
✓ Branch 0 taken 66417 times.
✗ Branch 1 not taken.
66417 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18879 {
18880 return qe_invalid;
18881 }
18882 66417 }
18883
18884
2/2
✓ Branch 0 taken 66417 times.
✓ Branch 1 taken 22139 times.
88556 for(int32_t j=0; j<3; j++)
18885 {
18886
1/2
✓ Branch 0 taken 66417 times.
✗ Branch 1 not taken.
66417 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18887 {
18888 return qe_invalid;
18889 }
18890 66417 }
18891 22139 }
18892
18893 763 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18894 763 }
18895
18896 786 return 0;
18897 787 }
18898
18899 787 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18900 {
18901
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 24 times.
787 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18902
18903 787 int32_t tiles_used=0;
18904 787 word section_version = 0;
18905 787 int32_t section_size= 0;
18906 787 byte *temp_tile = new byte[tilesize(tf32Bit)];
18907
18908 //Tile Expansion
18909 //if ( version >= 0x254 && build >= 41 )
18910
4/4
✓ Branch 0 taken 605 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 599 times.
787 if (version < 0x254 && build < 41)
18911 {
18912 599 max_tiles = ZC250MAXTILES;
18913 599 }
18914
18915
18916
2/6
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 787 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
787 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18917 {
18918 if(!init_tiles_for_190(true, Header))
18919 {
18920 al_trace("Unable to initialize tiles\n");
18921 }
18922
18923 delete[] temp_tile;
18924 temp_tile=NULL;
18925 return 0;
18926 }
18927 else
18928 {
18929
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(version > 0x192)
18930 {
18931 //section version info
18932
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&section_version,f))
18933 {
18934 delete[] temp_tile;
18935 return qe_invalid;
18936 }
18937
18938 763 FFCore.quest_format[vTiles] = section_version;
18939
18940
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!read_deprecated_section_cversion(f))
18941 {
18942 delete[] temp_tile;
18943 return qe_invalid;
18944 }
18945
18946 //section size
18947
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetl(&section_size,f))
18948 {
18949 delete[] temp_tile;
18950 return qe_invalid;
18951 }
18952 763 }
18953
18954 //if ( build < 41 )
18955 //{
18956 // tiles_used = ZC250MAXTILES;
18957 //}
18958
18959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if(version < 0x174)
18960 {
18961 tiles_used=TILES_PER_PAGE*4;
18962 } //no expanded tile space
18963
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 769 times.
787 else if(version < 0x191)
18964 {
18965 18 tiles_used=OLDMAXTILES;
18966 18 }
18967 else
18968 {
18969 //finally... section data
18970
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
769 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18971 {
18972
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&tiles_used,f))
18973 {
18974 delete[] temp_tile;
18975 return qe_invalid;
18976 }
18977 182 }
18978 else
18979 {
18980
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(!p_igetw(&tiles_used,f))
18981 {
18982 delete[] temp_tile;
18983 return qe_invalid;
18984 }
18985 }
18986 }
18987
18988
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 tiles_used=zc_min(tiles_used, max_tiles);
18989
18990 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18991 //if ( version < 0x254 && build < 41 )
18992
3/6
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
787 if ( version < 0x254 || (version == 0x254 && build < 41) )
18993 //if ( build < 41 )
18994 {
18995
1/2
✓ Branch 0 taken 605 times.
✗ Branch 1 not taken.
605 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18996 605 }
18997 else //2.55
18998 {
18999
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19000 }
19001
19002 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19003
19004
19005
2/2
✓ Branch 0 taken 18117181 times.
✓ Branch 1 taken 787 times.
18117968 for(int32_t i=0; i<tiles_used; ++i)
19006 {
19007 18117181 byte format=tf4Bit;
19008 18117181 memset(temp_tile, 0, tilesize(tf32Bit));
19009
19010
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 15131725 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18117181 if((version>0x211)||((version==0x211)&&(build>4)))
19011 {
19012
1/2
✓ Branch 0 taken 15131725 times.
✗ Branch 1 not taken.
15131725 if(!p_getc(&format,f))
19013 {
19014 delete[] temp_tile;
19015 return qe_invalid;
19016 }
19017 15131725 }
19018
4/4
✓ Branch 0 taken 6930112 times.
✓ Branch 1 taken 11187069 times.
✓ Branch 2 taken 3173335 times.
✓ Branch 3 taken 3756777 times.
18117181 if(section_version > 2 && !format)
19019 {
19020 3756777 reset_tile(buf,start_tile+i,tf4Bit);
19021 3756777 continue;
19022 }
19023
19024
2/2
✓ Branch 0 taken 13870901 times.
✓ Branch 1 taken 489503 times.
14360404 int size = format == tf4Bit ? 128 : tilesize(format);
19025
1/2
✓ Branch 0 taken 14360404 times.
✗ Branch 1 not taken.
14360404 if(!pfread(temp_tile,size,f))
19026 {
19027 delete[] temp_tile;
19028 return qe_invalid;
19029 }
19030
19031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14360404 times.
14360404 if (should_skip)
19032 continue;
19033
19034 14360404 buf[start_tile+i].format=format;
19035
19036
2/2
✓ Branch 0 taken 14156519 times.
✓ Branch 1 taken 203885 times.
14360404 if(buf[start_tile+i].data)
19037 {
19038 14156519 free(buf[start_tile+i].data);
19039 14156519 buf[start_tile+i].data=NULL;
19040 14156519 }
19041
19042 14360404 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19043
19044
2/2
✓ Branch 0 taken 13870901 times.
✓ Branch 1 taken 489503 times.
14360404 if (format == tf4Bit)
19045 {
19046 byte temp[256];
19047 13870901 byte *si = temp_tile + 128;
19048 13870901 byte *di = temp + 256;
19049
19050
2/2
✓ Branch 0 taken 1775475328 times.
✓ Branch 1 taken 13870901 times.
1789346229 for(int i=127; i>=0; --i)
19051 {
19052 1775475328 (*(--di)) = (*(--si)) >> 4;
19053 1775475328 (*(--di)) = (*si) & 15;
19054 1775475328 }
19055
19056 13870901 memcpy(buf[start_tile+i].data,temp,256);
19057 13870901 }
19058 else
19059 {
19060 489503 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19061 }
19062 14360404 }
19063 }
19064
19065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if (should_skip)
19066 return 0;
19067
19068
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 605 times.
787 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19069 {
19070
2/2
✓ Branch 0 taken 90132900 times.
✓ Branch 1 taken 605 times.
90133505 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19071 {
19072
19073 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19074 90132900 reset_tile(buf,q,tf4Bit);
19075
19076
19077 /*
19078
19079 byte tempbyte;
19080 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19081 {
19082 tempbyte=buf[ZC250MAXTILES-1].data[i];
19083 buf[q].data[i] = tempbyte;
19084 }
19085 //int32_t temp = tempbyte=buf[130].data[i];
19086 //buf[q].data = buf[ZC250MAXTILES-1].data;
19087 */
19088 //reset_tile(buf,q,tf4Bit);
19089 90132900 }
19090
19091 605 }
19092
19093
4/6
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 605 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 182 times.
787 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19094 {
19095
2/2
✓ Branch 0 taken 29920127 times.
✓ Branch 1 taken 605 times.
29920732 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19096 {
19097 29920127 reset_tile(buf,i,tf4Bit);
19098 29920127 }
19099 605 }
19100 else
19101 {
19102
2/2
✓ Branch 0 taken 31535172 times.
✓ Branch 1 taken 182 times.
31535354 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19103 {
19104 31535172 reset_tile(buf,i,tf4Bit);
19105 31535172 }
19106 }
19107
19108
5/6
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 763 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
787 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19109 {
19110
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19111 {
19112 byte tempbyte;
19113 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19114
19115
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19116 {
19117 1536 tempbyte=buf[23].data[i];
19118 1536 buf[23].data[i]=buf[24].data[i];
19119 1536 buf[24].data[i]=buf[25].data[i];
19120 1536 buf[25].data[i]=buf[26].data[i];
19121 1536 buf[26].data[i]=tempbyte;
19122 1536 }
19123 //swim tiles are out of order, too, but nobody cared? -Z
19124
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19125 {
19126 1536 tempbyte=buf[floattile+11].data[i];
19127 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19128 1536 buf[floattile+12].data[i]=tempbyte;
19129 1536 }
19130 6 }
19131 24 }
19132
19133
3/6
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 704 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
787 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19134 {
19135
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19136 {
19137 byte tempbyte;
19138
19139
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19140 {
19141 5632 tempbyte=buf[130].data[i];
19142 5632 buf[130].data[i]=buf[132].data[i];
19143 5632 buf[132].data[i]=tempbyte;
19144
19145 5632 tempbyte=buf[131].data[i];
19146 5632 buf[131].data[i]=buf[133].data[i];
19147 5632 buf[133].data[i]=tempbyte;
19148 5632 }
19149 22 }
19150 83 }
19151
19152 787 al_trace("Registering blank tiles\n");
19153 787 register_blank_tiles();
19154
19155 //memset(temp_tile, 0, tilesize(tf32Bit));
19156
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 delete[] temp_tile;
19157 787 temp_tile=NULL;
19158 787 return 0;
19159 787 }
19160
19161 469 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19162 {
19163
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
469 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19164
19165 static byte fake_midi_flags[32];
19166
19167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19168 int32_t dummy;
19169 word dummy2;
19170 // zcmidi_ temp_midi;
19171 int32_t tunes_to_read;
19172 469 int32_t tune_count=0;
19173 469 word section_version=0;
19174 469 zctune temp;
19175
19176
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 446 times.
469 if(Header->zelda_version < 0x193)
19177 {
19178 // mf=Header->data_flags+ZQ_MIDIS2;
19179
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19180 {
19181 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19182 22 }
19183 else
19184 {
19185 1 tunes_to_read=MAXCUSTOMTUNES;
19186 }
19187 23 }
19188 else
19189 {
19190 //section version info
19191
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&section_version,f))
19192 {
19193 return qe_invalid;
19194 }
19195
19196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if (!should_skip)
19197 446 FFCore.quest_format[vMIDIs] = section_version;
19198
19199
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&dummy2,f))
19200 {
19201 return qe_invalid;
19202 }
19203
19204 //section size
19205
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy,f))
19206 {
19207 return qe_invalid;
19208 }
19209
19210 //finally... section data
19211
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!pfread(midi_flags,sizeof(midi_flags),f))
19212 {
19213 return qe_invalid;
19214 }
19215
19216 446 tunes_to_read=MAXCUSTOMTUNES;
19217 }
19218
19219
2/2
✓ Branch 0 taken 118188 times.
✓ Branch 1 taken 469 times.
118657 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19220 {
19221
2/2
✓ Branch 0 taken 10242 times.
✓ Branch 1 taken 107946 times.
118188 if(get_bit(mf, i))
19222 {
19223 10242 ++tune_count;
19224 10242 }
19225 118188 }
19226
19227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (!should_skip)
19228 469 reset_tunes(tunes); //reset_midis(midis);
19229
19230
2/2
✓ Branch 0 taken 113348 times.
✓ Branch 1 taken 469 times.
113817 for(int32_t i=0; i<tunes_to_read; i++)
19231 {
19232 113348 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19233
19234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113348 times.
113348 if (!should_skip)
19235 113348 tunes[i].reset(); // reset_midi(midis+i);
19236
19237
2/2
✓ Branch 0 taken 103106 times.
✓ Branch 1 taken 10242 times.
113348 if(get_bit(mf,i))
19238 {
19239
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7579 times.
10242 if(section_version < 4)
19240 {
19241
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19242 {
19243 return qe_invalid;
19244 }
19245 2663 }
19246 else
19247 {
19248
1/2
✓ Branch 0 taken 7579 times.
✗ Branch 1 not taken.
7579 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19249 {
19250 return qe_invalid;
19251 }
19252 }
19253
19254
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!p_igetl(&temp.start,f))
19255 {
19256 return qe_invalid;
19257 }
19258
19259
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!p_igetl(&temp.loop_start,f))
19260 {
19261 return qe_invalid;
19262 }
19263
19264
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!p_igetl(&temp.loop_end,f))
19265 {
19266 return qe_invalid;
19267 }
19268
19269
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!p_igetw(&temp.loop,f))
19270 {
19271 return qe_invalid;
19272 }
19273
19274
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!p_igetw(&temp.volume,f))
19275 {
19276 return qe_invalid;
19277 }
19278
19279
2/2
✓ Branch 0 taken 9993 times.
✓ Branch 1 taken 249 times.
10242 if(Header->zelda_version < 0x193)
19280 {
19281
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19282 {
19283 return qe_invalid;
19284 }
19285 249 }
19286
19287
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7579 times.
10242 if(section_version >= 3)
19288 {
19289
1/2
✓ Branch 0 taken 7579 times.
✗ Branch 1 not taken.
7579 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19290 {
19291 return qe_invalid;
19292 }
19293 7579 }
19294
19295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10242 times.
10242 if (!should_skip)
19296 10242 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19297
19298
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7579 times.
10242 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19299 {
19300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19301 {
19302 if (read_midi(f)==NULL)
19303 {
19304 return qe_invalid;
19305 }
19306
19307 continue;
19308 }
19309
19310 // old format - a midi is a midi
19311
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19312 {
19313 return qe_invalid;
19314 }
19315 2663 }
19316 else
19317 {
19318 byte format;
19319
1/2
✓ Branch 0 taken 7579 times.
✗ Branch 1 not taken.
7579 if(!pfread(&format,sizeof(format),f))
19320 {
19321 return qe_invalid;
19322 }
19323
19324 // MIDI is the only format saved here.
19325 // Never did more than MIDI for a zctune, and no plans to now.
19326
1/2
✓ Branch 0 taken 7579 times.
✗ Branch 1 not taken.
7579 if (format != MFORMAT_MIDI)
19327 {
19328 return qe_invalid;
19329 }
19330
19331 7579 tunes[i].data = read_midi(f);
19332
1/2
✓ Branch 0 taken 7579 times.
✗ Branch 1 not taken.
7579 if (!tunes[i].data)
19333 {
19334 return qe_invalid;
19335 }
19336 }
19337 10242 }
19338 113348 }
19339
19340 469 return 0;
19341 469 }
19342
19343 469 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19344 {
19345
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
469 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19346
19347 int32_t dummy;
19348 ZCHEATS tempzcheats;
19349 469 char temp_use_cheats=1;
19350 469 memset(&tempzcheats, 0, sizeof(tempzcheats));
19351 469 word s_version = 0;
19352
19353
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 446 times.
469 if(Header->zelda_version > 0x192)
19354 {
19355 //section version info
19356
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&s_version,f))
19357 {
19358 return qe_invalid;
19359 }
19360
19361 446 FFCore.quest_format[vCheats] = s_version;
19362
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&dummy,f))
19363 {
19364 return qe_invalid;
19365 }
19366
19367 //section size
19368
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy,f))
19369 {
19370 return qe_invalid;
19371 }
19372
19373 //finally... section data
19374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(!p_getc(&temp_use_cheats,f))
19375 {
19376 return qe_invalid;
19377 }
19378 446 }
19379
19380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(Header->data_flags[ZQ_CHEATS2])
19381 {
19382
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetl(&tempzcheats.flags,f))
19383 {
19384 return qe_invalid;
19385 }
19386
19387
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19388 {
19389 return qe_invalid;
19390 }
19391 469 }
19392
19393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (should_skip)
19394 return 0;
19395
19396 469 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19397 469 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19398
19399 469 return 0;
19400 469 }
19401
19402 304 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19403 {
19404
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 281 times.
304 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19405
19406 byte padding, tempbyte;
19407
19408 // Legacy item properties (now integrated into itemdata)
19409 byte sword_hearts[4];
19410 byte beam_hearts[4];
19411 304 byte beam_percent=0;
19412 word beam_power[4];
19413 304 byte hookshot_length=99;
19414 304 byte hookshot_links=100;
19415 304 byte longshot_length=99;
19416 304 byte longshot_links=100;
19417 304 byte moving_fairy_hearts=3;
19418 304 byte moving_fairy_heart_percent=0;
19419 304 byte stationary_fairy_hearts=3;
19420 304 byte stationary_fairy_heart_percent=0;
19421 304 byte moving_fairy_magic=0;
19422 304 byte moving_fairy_magic_percent=0;
19423 304 byte stationary_fairy_magic=0;
19424 304 byte stationary_fairy_magic_percent=0;
19425 304 byte blue_potion_hearts=100;
19426 304 byte blue_potion_heart_percent=1;
19427 304 byte red_potion_hearts=100;
19428 304 byte red_potion_heart_percent=1;
19429 304 byte blue_potion_magic=100;
19430 304 byte blue_potion_magic_percent=1;
19431 304 byte red_potion_magic=100;
19432 304 byte red_potion_magic_percent=1;
19433
19434 304 byte bomb_ratio = 4;
19435
19436 304 subscr_mode = 0;
19437
19438 /* HIGHLY UNORTHODOX UPDATING THING, by L
19439 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19440 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19441 * changing from 13 to 14.
19442 */
19443
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(s_version < 14)
19444 82 fixpolsvoice=true;
19445
19446 /* End highly unorthodox updating thing */
19447
19448
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 114 times.
304 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19449 114 temp_zinit.jump_hero_layer_threshold=0;
19450
19451
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 222 times.
304 if(s_version >= 10)
19452 {
19453 char temp;
19454
19455 //new-style items
19456
2/2
✓ Branch 0 taken 56832 times.
✓ Branch 1 taken 222 times.
57054 for(int32_t j=0; j<256; j++)
19457 {
19458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56832 times.
56832 if(!p_getc(&temp,f))
19459 return qe_invalid;
19460
19461 56832 temp_zinit.set_item(j, temp != 0);
19462 56832 }
19463 222 }
19464
19465
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19466 {
19467 char temp;
19468
19469 //finally... section data
19470
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
291 if((Header->zelda_version > 0x192)||
19471 //new only
19472
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19473 {
19474 //OLD-style items... sigh
19475
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 60 times.
282 if(s_version < 10)
19476 {
19477
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19478 {
19479 return qe_invalid;
19480 }
19481
19482 60 temp_zinit.set_item(iRaft, temp != 0);
19483
19484
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19485 {
19486 return qe_invalid;
19487 }
19488
19489 60 temp_zinit.set_item(iLadder, temp != 0);
19490
19491
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19492 {
19493 return qe_invalid;
19494 }
19495
19496 60 temp_zinit.set_item(iBook, temp != 0);
19497
19498
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19499 {
19500 return qe_invalid;
19501 }
19502
19503 60 temp_zinit.set_item(iMKey, temp != 0);
19504
19505
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19506 {
19507 return qe_invalid;
19508 }
19509
19510 60 temp_zinit.set_item(iFlippers, temp != 0);
19511
19512
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19513 {
19514 return qe_invalid;
19515 }
19516
19517 60 temp_zinit.set_item(iBoots, temp != 0);
19518 60 }
19519 282 }
19520
19521
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 10)
19522 {
19523 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19524
19525
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19526 {
19527 return qe_invalid;
19528 }
19529
19530
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19531 {
19532 return qe_invalid;
19533 }
19534
19535
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19536 {
19537 return qe_invalid;
19538 }
19539
19540
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19541 {
19542 return qe_invalid;
19543 }
19544
19545
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19546 {
19547 return qe_invalid;
19548 }
19549
19550
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19551 {
19552 return qe_invalid;
19553 }
19554
19555
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19556 {
19557 return qe_invalid;
19558 }
19559
19560 //old only
19561
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19562 {
19563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19565
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19570 4 }
19571
19572 //rings start at level 2... wtf
19573 //account for this -DD
19574 64 tempring <<= 1;
19575 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19576 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19577 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19578 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19579 //bracelet ALSO starts at level 2 :-( -DD
19580 64 tempbracelet<<=1;
19581 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19582 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19583 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19584
19585 //new only
19586
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
19587 {
19588
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19589 {
19590
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19591 {
19592 return qe_invalid;
19593 }
19594 32 }
19595 1 }
19596
19597 char tempcandle, tempboomerang, temparrow, tempwhistle;
19598
19599
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
19600 {
19601 return qe_invalid;
19602 }
19603
19604
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
19605 {
19606 return qe_invalid;
19607 }
19608
19609
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
19610 {
19611 return qe_invalid;
19612 }
19613
19614
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
19615 {
19616 return qe_invalid;
19617 }
19618
19619 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19620
19621
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
19622 {
19623 return qe_invalid;
19624 }
19625
19626 //old only
19627
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19628 {
19629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19633 4 }
19634
19635 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19636 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19637 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19638 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19639 //What about the potion...?
19640
19641 64 }
19642
19643
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if(s_version < 29)
19644 {
19645 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19646 //to jab out my eye...
19647
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19648 return qe_invalid;
19649 269 temp_zinit.counter[crBOMBS] = padding;
19650
19651
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19652 return qe_invalid;
19653 269 temp_zinit.counter[crSBOMBS] = padding;
19654 269 }
19655
19656 //Back to more OLD item code
19657
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 10)
19658 {
19659
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
19660 //new only
19661
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19662 {
19663
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19664 {
19665 return qe_invalid;
19666 }
19667
19668 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19669
19670
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19671 {
19672 return qe_invalid;
19673 }
19674
19675 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19676
19677
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19678 {
19679 return qe_invalid;
19680 }
19681
19682 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19683
19684
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19685 {
19686 return qe_invalid;
19687 }
19688
19689 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19690
19691
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19692 {
19693 return qe_invalid;
19694 }
19695
19696 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19697
19698
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19699 {
19700 return qe_invalid;
19701 }
19702
19703 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19704
19705
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19706 {
19707 return qe_invalid;
19708 }
19709
19710 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19711
19712
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19713 {
19714 return qe_invalid;
19715 }
19716
19717 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19718
19719
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19720 {
19721 return qe_invalid;
19722 }
19723
19724 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19725
19726
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19727 {
19728 return qe_invalid;
19729 }
19730
19731
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
19732 {
19733
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19734 {
19735
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19736 {
19737 return qe_invalid;
19738 }
19739 32 }
19740 1 }
19741 60 }
19742 64 }
19743
19744 //old only
19745
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
19746 {
19747 byte equipment, tmpitm; //bit flags
19748
19749
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
19750 {
19751 return qe_invalid;
19752 }
19753
19754 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19755 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19756 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19757 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19758 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19759 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19760
19761
19762
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
19763 {
19764 return qe_invalid;
19765 }
19766
19767 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19768 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19769 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19770 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19771 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19772 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19773 4 }
19774
19775
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&tempbyte,f))
19776 return qe_invalid;
19777 286 temp_zinit.mcounter[crLIFE] = tempbyte;
19778
19779
19780
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 14)
19781 {
19782 byte temphp;
19783
19784
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19785 {
19786 return qe_invalid;
19787 }
19788
19789 64 temp_zinit.counter[crLIFE]=temphp;
19790
19791
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19792 {
19793 return qe_invalid;
19794 }
19795
19796 64 temp_zinit.cont_heart=temphp;
19797 64 }
19798 else
19799 {
19800
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19801 {
19802 return qe_invalid;
19803 }
19804
19805
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.cont_heart,f))
19806 {
19807 return qe_invalid;
19808 }
19809 }
19810
19811
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.hcp,f))
19812 {
19813 return qe_invalid;
19814 }
19815
19816
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version >= 14)
19817 {
19818
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19819 {
19820 return qe_invalid;
19821 }
19822
19823
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(s_version<16) // July 2007
19824 {
19825 if(get_qr(qr_BRANGPICKUP+1))
19826 temp_zinit.hcp_per_hc = 0xFF;
19827
19828 //Dispose of legacy rule
19829 set_qr(qr_BRANGPICKUP+1, 0);
19830 }
19831 222 }
19832
19833
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if(s_version < 29)
19834 {
19835
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19836 return qe_invalid;
19837 269 temp_zinit.mcounter[crBOMBS] = padding;
19838 269 }
19839
19840
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19841 {
19842 return qe_invalid;
19843 }
19844
19845
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19846 {
19847 return qe_invalid;
19848 }
19849
19850
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&tempbyte,f))
19851 return qe_invalid;
19852
2/2
✓ Branch 0 taken 2288 times.
✓ Branch 1 taken 286 times.
2574 for(int q = 0; q < 8; ++q)
19853
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 1784 times.
2288 SETFLAG(temp_zinit.litems[q+1], liTRIFORCE, get_bitl(tempbyte, q));
19854
19855 286 int level_count = 32;
19856
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
286 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19857 222 level_count = 64;
19858 byte tmp_map[64];
19859 byte tmp_compass[64];
19860
2/2
✓ Branch 0 taken 16256 times.
✓ Branch 1 taken 286 times.
16542 for(int32_t i=0; i<level_count; i++)
19861
1/2
✓ Branch 0 taken 16256 times.
✗ Branch 1 not taken.
16256 if(!p_getc(&tmp_map[i],f))
19862 return qe_invalid;
19863
2/2
✓ Branch 0 taken 16256 times.
✓ Branch 1 taken 286 times.
16542 for(int32_t i=0; i<level_count; i++)
19864
1/2
✓ Branch 0 taken 16256 times.
✗ Branch 1 not taken.
16256 if(!p_getc(&tmp_compass[i],f))
19865 return qe_invalid;
19866
2/2
✓ Branch 0 taken 130048 times.
✓ Branch 1 taken 286 times.
130334 for(int q = 0; q < level_count*8; ++q)
19867 {
19868
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 129252 times.
130048 SETFLAG(temp_zinit.litems[q], liMAP, get_bit(tmp_map, q));
19869
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 130039 times.
130048 SETFLAG(temp_zinit.litems[q], liCOMPASS, get_bit(tmp_compass, q));
19870 130048 }
19871
19872
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
291 if((Header->zelda_version > 0x192)||
19873 //new only
19874
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19875 {
19876 byte tmp_boss_key[64];
19877
2/2
✓ Branch 0 taken 16128 times.
✓ Branch 1 taken 282 times.
16410 for(int32_t i=0; i<level_count; i++)
19878 {
19879
1/2
✓ Branch 0 taken 16128 times.
✗ Branch 1 not taken.
16128 if(!p_getc(&tmp_boss_key[i],f))
19880 {
19881 return qe_invalid;
19882 }
19883 16128 }
19884
2/2
✓ Branch 0 taken 129024 times.
✓ Branch 1 taken 282 times.
129306 for(int q = 0; q < level_count*8; ++q)
19885 {
19886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129024 times.
129024 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
19887 129024 }
19888 282 }
19889
19890 byte tmpmisc[16];
19891
2/2
✓ Branch 0 taken 4576 times.
✓ Branch 1 taken 286 times.
4862 for(int32_t i=0; i<16; i++)
19892
1/2
✓ Branch 0 taken 4576 times.
✗ Branch 1 not taken.
4576 if(!p_getc(&tmpmisc[i],f))
19893 return qe_invalid;
19894 286 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19895 286 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19896 286 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19897
19898
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
542 if(s_version < 15) for(int32_t i=0; i<4; i++)
19899
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
19900 64 return qe_invalid;
19901
19902
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.last_map,f))
19903 {
19904 return qe_invalid;
19905 }
19906
19907
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.last_screen,f))
19908 {
19909 return qe_invalid;
19910 }
19911
19912
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 14)
19913 {
19914 byte tempmp;
19915
19916
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19917 {
19918 return qe_invalid;
19919 }
19920
19921 64 temp_zinit.mcounter[crMAGIC]=tempmp;
19922
19923
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19924 {
19925 return qe_invalid;
19926 }
19927
19928 64 temp_zinit.counter[crMAGIC]=tempmp;
19929 64 }
19930 else
19931 {
19932
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
19933 {
19934 return qe_invalid;
19935 }
19936
19937
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
19938 {
19939 return qe_invalid;
19940 }
19941 }
19942
19943
19944
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 15)
19945 {
19946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
19947 {
19948 64 temp_zinit.mcounter[crMAGIC]*=32;
19949 64 temp_zinit.counter[crMAGIC]*=32;
19950 64 }
19951
19952
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19953 {
19954
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
19955 {
19956 return qe_invalid;
19957 }
19958 256 }
19959
19960
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
19961 {
19962 return qe_invalid;
19963 }
19964 64 }
19965 else
19966 {
19967
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.bomb_ratio,f))
19968 return qe_invalid;
19969
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(temp_zinit.bomb_ratio < 1)
19970 temp_zinit.bomb_ratio = 1;
19971 222 else bomb_ratio = temp_zinit.bomb_ratio; //jank
19972 }
19973
19974
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 15)
19975 {
19976 byte tempbp;
19977
19978
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19979 {
19980
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19981 {
19982 return qe_invalid;
19983 }
19984
19985 256 beam_power[i]=tempbp;
19986 256 }
19987
19988
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
19989 {
19990 return qe_invalid;
19991 }
19992
19993
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
19994 {
19995 if(!p_getc(&hookshot_length,f))
19996 {
19997 return qe_invalid;
19998 }
19999
20000 if(!p_getc(&longshot_links,f))
20001 {
20002 return qe_invalid;
20003 }
20004
20005 if(!p_getc(&longshot_length,f))
20006 {
20007 return qe_invalid;
20008 }
20009 }
20010 64 }
20011
20012
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.msg_more_x,f))
20013 {
20014 return qe_invalid;
20015 }
20016
20017
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.msg_more_y,f))
20018 {
20019 return qe_invalid;
20020 }
20021
20022
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&subscr_mode,f))
20023 return qe_invalid;
20024
20025 //old only
20026
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
20027 {
20028 byte tmp_boss_key[32];
20029
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20030 {
20031
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tmp_boss_key[i],f))
20032 {
20033 return qe_invalid;
20034 }
20035 128 }
20036
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int q = 0; q < 32*8; ++q)
20037 {
20038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
20039 1024 }
20040 4 }
20041
20042
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
286 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20043 {
20044
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 222 times.
282 if(s_version <= 10)
20045 {
20046
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20047 {
20048 return qe_invalid;
20049 }
20050
20051 60 temp_zinit.start_dmap = (word)tempbyte;
20052 60 }
20053 else
20054 {
20055
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.start_dmap,f))
20056 {
20057 return qe_invalid;
20058 }
20059 }
20060
20061
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20062 {
20063 return qe_invalid;
20064 }
20065 282 }
20066
20067
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 205 times.
286 if(s_version>1 && s_version < 29)
20068 {
20069
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&padding,f))
20070 return qe_invalid;
20071 205 temp_zinit.counter[crARROWS] = padding;
20072
20073
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&padding,f))
20074 return qe_invalid;
20075 205 temp_zinit.mcounter[crARROWS] = padding;
20076 205 }
20077
20078
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>2)
20079 {
20080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(s_version <= 10)
20081 {
20082 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20083 {
20084 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20085 {
20086 return qe_invalid;
20087 }
20088 }
20089 }
20090 else
20091 {
20092
2/2
✓ Branch 0 taken 113664 times.
✓ Branch 1 taken 222 times.
113886 for(int32_t i=0; i<MAXLEVELS; i++)
20093 {
20094
1/2
✓ Branch 0 taken 113664 times.
✗ Branch 1 not taken.
113664 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20095 {
20096 return qe_invalid;
20097 }
20098 113664 }
20099 }
20100 222 }
20101
20102
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>3)
20103 {
20104
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20105 {
20106 return qe_invalid;
20107 }
20108
20109
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20110 {
20111 return qe_invalid;
20112 }
20113
20114
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20115 {
20116 return qe_invalid;
20117 }
20118
20119
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20120 {
20121 return qe_invalid;
20122 }
20123
20124
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20125 {
20126 return qe_invalid;
20127 }
20128
20129
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20130 {
20131 return qe_invalid;
20132 }
20133
20134
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20135 {
20136 return qe_invalid;
20137 }
20138
20139
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_flags,f))
20140 {
20141 return qe_invalid;
20142 }
20143
20144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20146 222 }
20147
20148
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>4 && s_version<15)
20149 {
20150 if(!p_getc(&moving_fairy_hearts,f))
20151 {
20152 return qe_invalid;
20153 }
20154
20155 if(!p_getc(&moving_fairy_heart_percent,f))
20156 {
20157 return qe_invalid;
20158 }
20159 }
20160
20161
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>5 && s_version < 10)
20162 {
20163 if(!p_getc(&temp,f))
20164 {
20165 return qe_invalid;
20166 }
20167
20168 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20169 }
20170
20171
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>6 && s_version<15)
20172 {
20173 if(!p_getc(&stationary_fairy_hearts,f))
20174 {
20175 return qe_invalid;
20176 }
20177
20178 if(!p_getc(&stationary_fairy_heart_percent,f))
20179 {
20180 return qe_invalid;
20181 }
20182
20183 if(!p_getc(&moving_fairy_magic,f))
20184 {
20185 return qe_invalid;
20186 }
20187
20188 if(!p_getc(&moving_fairy_magic_percent,f))
20189 {
20190 return qe_invalid;
20191 }
20192
20193 if(!p_getc(&stationary_fairy_magic,f))
20194 {
20195 return qe_invalid;
20196 }
20197
20198 if(!p_getc(&stationary_fairy_magic_percent,f))
20199 {
20200 return qe_invalid;
20201 }
20202
20203 if(!p_getc(&blue_potion_hearts,f))
20204 {
20205 return qe_invalid;
20206 }
20207
20208 if(!p_getc(&blue_potion_heart_percent,f))
20209 {
20210 return qe_invalid;
20211 }
20212
20213 if(!p_getc(&red_potion_hearts,f))
20214 {
20215 return qe_invalid;
20216 }
20217
20218 if(!p_getc(&red_potion_heart_percent,f))
20219 {
20220 return qe_invalid;
20221 }
20222
20223 if(!p_getc(&blue_potion_magic,f))
20224 {
20225 return qe_invalid;
20226 }
20227
20228 if(!p_getc(&blue_potion_magic_percent,f))
20229 {
20230 return qe_invalid;
20231 }
20232
20233 if(!p_getc(&red_potion_magic,f))
20234 {
20235 return qe_invalid;
20236 }
20237
20238 if(!p_getc(&red_potion_magic_percent,f))
20239 {
20240 return qe_invalid;
20241 }
20242 }
20243
20244
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>6)
20245
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20246 return qe_invalid;
20247
20248
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>7)
20249 {
20250
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20251 {
20252 return qe_invalid;
20253 }
20254 222 }
20255
20256
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>8)
20257 {
20258
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20259 {
20260 return qe_invalid;
20261 }
20262
20263
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20264 {
20265 return qe_invalid;
20266 }
20267 222 }
20268
20269
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version>16)
20270 {
20271
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&tempbyte,f))
20272 {
20273 return qe_invalid;
20274 }
20275 222 temp_zinit.gravity = tempbyte*100;
20276
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.terminalv,f))
20277 {
20278 return qe_invalid;
20279 }
20280
20281
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.msg_speed,f))
20282 {
20283 return qe_invalid;
20284 }
20285
20286
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20287 {
20288 return qe_invalid;
20289 }
20290
20291
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20292 {
20293 return qe_invalid;
20294 }
20295 222 }
20296
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20297 12 temp_zinit.msg_speed = 0;
20298
20299
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>17)
20300 {
20301
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20302 {
20303 return qe_invalid;
20304 }
20305 222 }
20306
20307 //expaned init data for larger values in 2.55
20308
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 17 times.
286 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20309 {
20310
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20311 {
20312 return qe_invalid;
20313 }
20314
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20315 {
20316 return qe_invalid;
20317 }
20318
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20319 {
20320 return qe_invalid;
20321 }
20322
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20323 {
20324 return qe_invalid;
20325 }
20326
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20327 {
20328 return qe_invalid;
20329 }
20330
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20331 {
20332 return qe_invalid;
20333 }
20334
20335 17 }
20336
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if ( s_version >= 20 )
20337 {
20338
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20339 {
20340 return qe_invalid;
20341 }
20342 17 }
20343 else
20344 {
20345 269 temp_zinit.heroStep = 150; //1.5 pixels per frame
20346 }
20347
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if ( s_version >= 21 )
20348 {
20349
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20350 {
20351 return qe_invalid;
20352 }
20353 17 }
20354 else
20355 {
20356 269 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20357 }
20358 //old only
20359
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
20360 {
20361 byte items2;
20362
20363
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20364 {
20365 return qe_invalid;
20366 }
20367
20368 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20369 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20370 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20371 4 }
20372
20373
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 5 times.
286 if(Header->zelda_version < 0x193)
20374 {
20375
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20376 {
20377
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20378 {
20379 return qe_invalid;
20380 }
20381 480 }
20382
20383 //new only
20384
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20385 {
20386
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20387 {
20388 return qe_invalid;
20389 }
20390
20391
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20392 {
20393 return qe_invalid;
20394 }
20395 1 }
20396 5 }
20397 286 }
20398
20399
3/6
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 222 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20400 {
20401 //temp_zinit.shield=i_smallshield;
20402 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20403
20404
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20405 82 temp_zinit.set_item(sshieldid, true);
20406 82 }
20407
20408
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20409 {
20410 18 temp_zinit.mcounter[crLIFE]=3;
20411 18 temp_zinit.counter[crLIFE]=3;
20412 18 temp_zinit.cont_heart=3;
20413 18 temp_zinit.mcounter[crBOMBS]=8;
20414 18 }
20415
20416
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20417 {
20418 18 sword_hearts[0]=0;
20419 18 sword_hearts[1]=5;
20420 18 sword_hearts[2]=12;
20421 18 sword_hearts[3]=21;
20422 18 }
20423
20424
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20425 {
20426 18 temp_zinit.last_map=0;
20427 18 temp_zinit.last_screen=0;
20428 18 }
20429
20430
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20431 {
20432 18 temp_zinit.mcounter[crMAGIC]=0;
20433 18 temp_zinit.counter[crMAGIC]=0;
20434 18 temp_zinit.magicdrainrate = 2;
20435 18 }
20436
20437
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20438 {
20439
20440
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20441 {
20442 72 beam_hearts[x]=100;
20443 72 }
20444
20445
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20446 {
20447 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20448 72 set_qr(qr_LENSHINTS+i,0);
20449 72 }
20450
20451
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20452 {
20453 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20454 72 }
20455
20456 18 set_qr(qr_HIDECARRIEDITEMS,0);
20457 18 hookshot_links=100;
20458 18 temp_zinit.msg_more_x=224;
20459 18 temp_zinit.msg_more_y=64;
20460 18 }
20461
20462 // Okay, let's put these legacy values into itemsbuf.
20463
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(s_version < 15)
20464
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20465 {
20466
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20467 {
20468 case iFairyStill:
20469 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20470 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20471 82 itemsbuf[i].misc3 = 0;
20472
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20473
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20474 82 break;
20475
20476 case iFairyMoving:
20477 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20478 82 itemsbuf[i].misc2 = moving_fairy_magic;
20479 82 itemsbuf[i].misc3 = 50;
20480
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20481
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20482 82 break;
20483
20484 case iRPotion:
20485 82 itemsbuf[i].misc1 = red_potion_hearts;
20486 82 itemsbuf[i].misc2 = red_potion_magic;
20487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20489 82 break;
20490
20491 case iBPotion:
20492 82 itemsbuf[i].misc1 = blue_potion_hearts;
20493 82 itemsbuf[i].misc2 = blue_potion_magic;
20494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20496 82 break;
20497
20498 case iSword:
20499 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20500 82 itemsbuf[i].misc1 = beam_hearts[0];
20501 82 itemsbuf[i].misc2 = beam_power[0];
20502 // It seems that item_flag1 was already added by reset_itembuf()...
20503 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20504 82 break;
20505
20506 case iWSword:
20507 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20508 82 itemsbuf[i].misc1 = beam_hearts[1];
20509 82 itemsbuf[i].misc2 = beam_power[1];
20510 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20511 82 break;
20512
20513 case iMSword:
20514 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20515 82 itemsbuf[i].misc1 = beam_hearts[2];
20516 82 itemsbuf[i].misc2 = beam_power[2];
20517 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20518 82 break;
20519
20520 case iXSword:
20521 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20522 82 itemsbuf[i].misc1 = beam_hearts[3];
20523 82 itemsbuf[i].misc2 = beam_power[3];
20524 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20525 82 break;
20526
20527 case iHookshot:
20528 82 itemsbuf[i].misc1 = hookshot_length;
20529 82 itemsbuf[i].misc2 = hookshot_links;
20530 82 break;
20531
20532 case iLongshot:
20533 82 itemsbuf[i].misc1 = longshot_length;
20534 82 itemsbuf[i].misc2 = longshot_links;
20535 82 break;
20536 }
20537 21074 }
20538
20539
6/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20540 {
20541 //was new subscreen rule
20542 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20543 22 set_qr(qr_FREEFORM,0);
20544 22 }
20545
20546
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20547 {
20548 23 temp_zinit.start_dmap=0;
20549 23 }
20550
20551
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20552 {
20553 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20554 23 }
20555
20556
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
304 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20557 {
20558 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20559 temp_zinit.mcounter[crMONEY]=999;
20560 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20561 }
20562
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 6 times.
304 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20563 {
20564 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20565 6 temp_zinit.mcounter[crBOMBS] = 8;
20566 6 }
20567 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20568 //time to ensure that we port all new values properly:
20569
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(Header->zelda_version < 0x250)
20570 {
20571
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20572 82 }
20573
20574
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 21)
20575 {
20576
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
20577 {
20578 return qe_invalid;
20579 }
20580
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
20581 {
20582 return qe_invalid;
20583 }
20584
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20585 {
20586 return qe_invalid;
20587 }
20588
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20589 {
20590 return qe_invalid;
20591 }
20592 17 }
20593 else
20594 {
20595 287 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20596 287 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20597 287 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20598 287 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20599 }
20600
20601
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 22)
20602 {
20603
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
20605 return qe_invalid;
20606
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
20608 return qe_invalid;
20609 17 }
20610
20611
20612
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 23)
20613 {
20614
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
20615 {
20616 return qe_invalid;
20617 }
20618
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
20619 {
20620 return qe_invalid;
20621 }
20622
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
20623 {
20624 return qe_invalid;
20625 }
20626
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
20627 {
20628 return qe_invalid;
20629 }
20630
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
20631 {
20632 return qe_invalid;
20633 }
20634 17 }
20635 else
20636 {
20637 287 temp_zinit.dither_type = 0;
20638 287 temp_zinit.dither_arg = 0;
20639 287 temp_zinit.dither_percent = 20;
20640 287 temp_zinit.def_lightrad = 24;
20641 287 temp_zinit.transdark_percent = 0;
20642 }
20643
20644
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 24)
20645 {
20646
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
20647 {
20648 return qe_invalid;
20649 }
20650 17 }
20651 else
20652 {
20653 287 temp_zinit.darkcol = BLACK;
20654 }
20655
20656
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 25)
20657 {
20658
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
20659 {
20660 return qe_invalid;
20661 }
20662
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
20663 {
20664 return qe_invalid;
20665 }
20666 17 }
20667
20668
20669
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 26)
20670 {
20671
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20672 {
20673 return qe_invalid;
20674 }
20675
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20676 {
20677 return qe_invalid;
20678 }
20679
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20680 {
20681 return qe_invalid;
20682 }
20683 17 }
20684 else
20685 {
20686 287 temp_zinit.heroSideswimUpStep = 150;
20687 287 temp_zinit.heroSideswimSideStep = 100;
20688 287 temp_zinit.heroSideswimDownStep = 75;
20689 }
20690
20691
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 27)
20692 {
20693
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20694 {
20695 return qe_invalid;
20696 }
20697 17 }
20698 else
20699 {
20700 287 temp_zinit.exitWaterJump = 0;
20701 }
20702
20703
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 29)
20704 {
20705
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20706 {
20707 return qe_invalid;
20708 }
20709 17 }
20710 else
20711 {
20712 287 temp_zinit.bunny_ltm = 0;
20713 }
20714
20715
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 30)
20716 {
20717
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
20718 {
20719 return qe_invalid;
20720 }
20721 17 }
20722 else
20723 {
20724 287 temp_zinit.switchhookstyle = 1;
20725 }
20726
20727
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 31)
20728 {
20729
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
20730 {
20731 return qe_invalid;
20732 }
20733 17 }
20734
20735 304 temp_zinit.clear_genscript();
20736
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 12 times.
304 if(s_version > 32)
20737 {
20738 12 word numgenscript = 0;
20739
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
20740 return qe_invalid;
20741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
20742 return qe_invalid;
20743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
20744 {
20745 if(!p_getc(&tempbyte,f))
20746 return qe_invalid;
20747 if(!(tempbyte&2))
20748 continue;
20749 temp_zinit.gen_doscript.set(q, tempbyte&1);
20750 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20751 return qe_invalid;
20752 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20753 return qe_invalid;
20754 for(auto p = 0; p < 8; ++p)
20755 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20756 return qe_invalid;
20757 dword sz;
20758 if(!p_igetl(&sz,f))
20759 return qe_invalid;
20760 temp_zinit.gen_data[q].resize(sz);
20761 std::vector<int32_t> dummy;
20762 if(!p_getlvec(&dummy,f))
20763 return qe_invalid;
20764 temp_zinit.gen_data[q] = dummy;
20765 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20766 return qe_invalid;
20767 }
20768 12 }
20769
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 6 times.
304 if(s_version > 33)
20770 {
20771
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20772 return qe_invalid;
20773
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
20774 return qe_invalid;
20775 6 }
20776
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(s_version > 34)
20777 {
20778 uint32_t num_used_mapscr_data;
20779 if(!p_igetl(&num_used_mapscr_data,f))
20780 return qe_invalid;
20781 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20782 {
20783 uint32_t sz;
20784 if(!p_igetl(&sz,f))
20785 return qe_invalid;
20786 temp_zinit.screen_data[q].resize(sz);
20787 if(sz)
20788 {
20789 std::vector<int32_t> dummy;
20790 if(!p_getlvec(&dummy,f))
20791 return qe_invalid;
20792 temp_zinit.screen_data[q] = dummy;
20793 }
20794 }
20795 }
20796
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (s_version > 35)
20797 if(!p_igetzf(&temp_zinit.shove_offset,f))
20798 return qe_invalid;
20799
20800 304 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20801 304 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20802
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 110 times.
304 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20803 110 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20804
20805 304 return 0;
20806 304 }
20807 469 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20808 {
20809 469 zinitdata temp_zinit = {};
20810
20811
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
469 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20812
20813 int32_t dummy;
20814 469 word s_version=0;
20815 byte padding;
20816
20817
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
469 if(Header->zelda_version > 0x192)
20818 {
20819
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&s_version,f))
20820 return qe_invalid;
20821 446 FFCore.quest_format[vInitData] = s_version;
20822
20823
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!read_deprecated_section_cversion(f))
20824 return qe_invalid;
20825
20826 //section size
20827
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&dummy,f))
20828 return qe_invalid;
20829 446 }
20830
20831
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 165 times.
469 if(s_version < 37)
20832 {
20833
2/4
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 304 times.
304 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
20834 return ret;
20835 304 }
20836 else
20837 {
20838 165 subscr_mode = ssdtMAX;
20839
2/2
✓ Branch 0 taken 5280 times.
✓ Branch 1 taken 165 times.
5445 for(int q = 0; q < MAXITEMS/8; ++q)
20840
2/4
✓ Branch 0 taken 5280 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5280 times.
5280 if(!p_getc(&temp_zinit.items[q], f))
20841 return qe_invalid;
20842
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 46 times.
165 if(s_version >= 42)
20843 {
20844
2/2
✓ Branch 0 taken 60928 times.
✓ Branch 1 taken 119 times.
61047 for(int q = 0; q < MAXLEVELS; ++q)
20845 {
20846
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60928 times.
60928 if(!p_getc(&temp_zinit.litems[q], f))
20847 return qe_invalid;
20848 60928 }
20849 119 }
20850 else
20851 {
20852 byte tmp_map[MAXLEVELS/8];
20853 byte tmp_compass[MAXLEVELS/8];
20854 byte tmp_boss_key[MAXLEVELS/8];
20855 byte tmp_mcguffin[MAXLEVELS/8];
20856
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 46 times.
2990 for(int q = 0; q < MAXLEVELS/8; ++q)
20857 {
20858
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_map[q], f))
20859 return qe_invalid;
20860
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_compass[q], f))
20861 return qe_invalid;
20862
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_boss_key[q], f))
20863 return qe_invalid;
20864
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_mcguffin[q], f))
20865 return qe_invalid;
20866 2944 }
20867
2/2
✓ Branch 0 taken 23552 times.
✓ Branch 1 taken 46 times.
23598 for(int q = 0; q < MAXLEVELS; ++q)
20868 {
20869
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23552 times.
23552 SETFLAG(temp_zinit.litems[q], liMAP, get_bit(tmp_map, q));
20870
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 23532 times.
23552 SETFLAG(temp_zinit.litems[q], liCOMPASS, get_bit(tmp_compass, q));
20871
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23552 times.
23552 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
20872
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 23408 times.
23552 SETFLAG(temp_zinit.litems[q], liTRIFORCE, get_bit(tmp_mcguffin, q));
20873 23552 }
20874 }
20875
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbvec(&temp_zinit.level_keys, f))
20876 return qe_invalid;
20877 byte num_counters;
20878
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&num_counters,f))
20879 return qe_invalid;
20880
2/2
✓ Branch 0 taken 17655 times.
✓ Branch 1 taken 165 times.
17820 for(int q = 0; q < num_counters; ++q)
20881
2/4
✓ Branch 0 taken 17655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17655 times.
17655 if(!p_igetw(&temp_zinit.counter[q],f))
20882 return qe_invalid;
20883
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 17655 times.
17820 for(int q = 0; q < num_counters; ++q)
20884
2/4
✓ Branch 0 taken 17655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17655 times.
17655 if(!p_igetw(&temp_zinit.mcounter[q],f))
20885 return qe_invalid;
20886
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.bomb_ratio,f))
20887 return qe_invalid;
20888
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hcp,f))
20889 return qe_invalid;
20890
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20891 return qe_invalid;
20892
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.cont_heart,f))
20893 return qe_invalid;
20894
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hp_per_heart,f))
20895 return qe_invalid;
20896
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.magic_per_block,f))
20897 return qe_invalid;
20898
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20899 return qe_invalid;
20900
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20901 return qe_invalid;
20902
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.dither_type,f))
20903 return qe_invalid;
20904
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.dither_arg,f))
20905 return qe_invalid;
20906
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.dither_percent,f))
20907 return qe_invalid;
20908
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.def_lightrad,f))
20909 return qe_invalid;
20910
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.transdark_percent,f))
20911 return qe_invalid;
20912
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.darkcol,f))
20913 return qe_invalid;
20914
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_grid_x,f))
20915 return qe_invalid;
20916
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_grid_y,f))
20917 return qe_invalid;
20918
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
20919 return qe_invalid;
20920
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 165 times.
165 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
20921 return qe_invalid;
20922
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_grid_color,f))
20923 return qe_invalid;
20924
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
20925 return qe_invalid;
20926
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
20927 return qe_invalid;
20928
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_flags,f))
20929 return qe_invalid;
20930
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbitstr(&temp_zinit.flags,f))
20931 return qe_invalid;
20932
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.last_map,f))
20933 return qe_invalid;
20934
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.last_screen,f))
20935 return qe_invalid;
20936
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.msg_more_x,f))
20937 return qe_invalid;
20938
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.msg_more_y,f))
20939 return qe_invalid;
20940
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20941 return qe_invalid;
20942
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.msg_speed,f))
20943 return qe_invalid;
20944
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.gravity,f))
20945 return qe_invalid;
20946
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.swimgravity,f))
20947 return qe_invalid;
20948
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.terminalv,f))
20949 return qe_invalid;
20950
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hero_swim_speed,f))
20951 return qe_invalid;
20952
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20953 return qe_invalid;
20954
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hero_swim_div,f))
20955 return qe_invalid;
20956
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20957 return qe_invalid;
20958
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20959 return qe_invalid;
20960
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20961 return qe_invalid;
20962
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20963 return qe_invalid;
20964
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.heroStep,f))
20965 return qe_invalid;
20966
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20967 return qe_invalid;
20968
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20969 return qe_invalid;
20970
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20971 return qe_invalid;
20972
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.start_dmap,f))
20973 return qe_invalid;
20974
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20975 return qe_invalid;
20976
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.switchhookstyle,f))
20977 return qe_invalid;
20978
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.magicdrainrate,f))
20979 return qe_invalid;
20980
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetzf(&temp_zinit.shove_offset,f))
20981 return qe_invalid;
20982
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
20983 return qe_invalid;
20984
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbmap(&temp_zinit.gen_exitState, f))
20985 return qe_invalid;
20986
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
20987 return qe_invalid;
20988
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 165 times.
165 if(!p_getbmap(&temp_zinit.gen_initd, f))
20989 return qe_invalid;
20990
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
20991 return qe_invalid;
20992
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbmap(&temp_zinit.gen_data, f))
20993 return qe_invalid;
20994
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbmap(&temp_zinit.screen_data, f))
20995 return qe_invalid;
20996
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if (s_version >= 38)
20997 {
20998
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
20999 return qe_invalid;
21000
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if (!p_getc(&temp_zinit.spriteflickercolor, f))
21001 return qe_invalid;
21002
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if (!p_getc(&temp_zinit.spriteflickertransp, f))
21003 return qe_invalid;
21004 165 }
21005
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 28 times.
165 if(s_version >= 39)
21006
2/4
✓ Branch 0 taken 137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
137 if(!p_igetzf(&temp_zinit.air_drag, f))
21007 return qe_invalid;
21008
21009 // TODO: this first branch can likely be removed, as it only fixes an issues
21010 // that existed for a handful of temporary z3 builds (and active users of that
21011 // fork would have been updating often, beyond s_version 40).
21012
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 137 times.
165 if (Header->is_z3 && s_version == 40)
21013 {
21014 if(!p_getc(&temp_zinit.region_mapping, f))
21015 return qe_invalid;
21016 }
21017 else
21018 {
21019
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 28 times.
165 if(s_version >= 40)
21020 {
21021
2/4
✓ Branch 0 taken 137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
137 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21022 return qe_invalid;
21023
2/4
✓ Branch 0 taken 137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
137 if(!p_igetw(&temp_zinit.light_wave_size, f))
21024 return qe_invalid;
21025 137 }
21026
21027
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 28 times.
165 if(s_version >= 41)
21028 {
21029
2/4
✓ Branch 0 taken 137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
137 if(!p_getc(&temp_zinit.region_mapping, f))
21030 return qe_invalid;
21031 137 }
21032 }
21033 }
21034
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if (should_skip)
21035 return 0;
21036
21037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(loading_tileset_flags & TILESET_CLEARMAPS)
21038 {
21039 temp_zinit.last_map = 0;
21040 temp_zinit.last_screen = 0;
21041 temp_zinit.screen_data.clear();
21042 }
21043
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 temp_zinit.normalize();
21044
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 zinit = temp_zinit;
21045
21046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(zinit.heroAnimationStyle==las_zelda3slow)
21047 {
21048 hero_animation_speed=2;
21049 }
21050 else
21051 {
21052 469 hero_animation_speed=1;
21053 }
21054
21055 469 return 0;
21056 469 }
21057
21058 /*
21059 void setupitemdropsets()
21060 {
21061 for(int32_t i=0; i<isMAX; i++)
21062 {
21063 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21064 }
21065 }
21066 */
21067
21068 410 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21069 {
21070
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 23 times.
410 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21071
21072 dword dummy_dword;
21073 410 word item_drop_sets_to_read=0;
21074 item_drop_object tempitemdrop;
21075 410 word s_version=0;
21076
21077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (!should_skip)
21078
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 410 times.
105370 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21079 {
21080 104960 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21081 105370 }
21082
21083
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 23 times.
410 if(version > 0x192)
21084 {
21085 387 item_drop_sets_to_read=0;
21086
21087 //section version info
21088
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&s_version,f))
21089 {
21090 return qe_invalid;
21091 }
21092
21093 387 FFCore.quest_format[vItemDropsets] = s_version;
21094
21095
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
21096 {
21097 return qe_invalid;
21098 }
21099
21100 //section size
21101
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy_dword,f))
21102 {
21103 return qe_invalid;
21104 }
21105
21106 //finally... section data
21107
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&item_drop_sets_to_read,f))
21108 {
21109 return qe_invalid;
21110 }
21111
21112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21113 {
21114 return qe_invalid;
21115 }
21116 387 }
21117 else
21118 {
21119 23 init_item_drop_sets();
21120 }
21121
21122
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 387 times.
410 if(s_version>=1)
21123 {
21124
2/2
✓ Branch 0 taken 5873 times.
✓ Branch 1 taken 387 times.
6260 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21125 {
21126
1/2
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
5873 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21127 {
21128 return qe_invalid;
21129 }
21130
21131
2/2
✓ Branch 0 taken 58730 times.
✓ Branch 1 taken 5873 times.
64603 for(int32_t j=0; j<10; ++j)
21132 {
21133
1/2
✓ Branch 0 taken 58730 times.
✗ Branch 1 not taken.
58730 if(!p_igetw(&tempitemdrop.item[j],f))
21134 {
21135 return qe_invalid;
21136 }
21137 58730 }
21138
21139
2/2
✓ Branch 0 taken 64603 times.
✓ Branch 1 taken 5873 times.
70476 for(int32_t j=0; j<11; ++j)
21140 {
21141
1/2
✓ Branch 0 taken 64603 times.
✗ Branch 1 not taken.
64603 if(!p_igetw(&tempitemdrop.chance[j],f))
21142 {
21143 return qe_invalid;
21144 }
21145 64603 }
21146
21147 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21148 // overrides the quest's set #12.
21149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5873 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5873 if(s_version<2 && i==12)
21150 continue;
21151
21152 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21153
1/4
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5873 if(s_version<2) for(int32_t j=0; j<10; ++j)
21154 {
21155 int32_t it = tempitemdrop.item[j];
21156
21157 if((itemsbuf[it].family == itype_rupee
21158 && ((itemsbuf[it].amount)&0xFFF) == 10)
21159 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21160 {
21161 tempitemdrop.chance[j+1]=0;
21162 }
21163 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21164 {
21165 tempitemdrop.chance[j+1]=0;
21166 }
21167
21168 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21169 if(itemsbuf[it].family == itype_misc)
21170 {
21171 // If a non-gameplay item was selected, then item drop was aborted.
21172 // Reflect this by increasing the 'Nothing' chance accordingly.
21173 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21174 tempitemdrop.chance[j+1]=0;
21175 }
21176 }
21177
21178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5873 times.
5873 if (!should_skip)
21179 5873 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21180 5873 }
21181 387 }
21182
21183 410 return 0;
21184 410 }
21185
21186 387 int32_t readfavorites(PACKFILE *f, int32_t)
21187 {
21188
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21189
21190 int32_t temp_num;
21191 dword dummy_dword;
21192 word num_favorite_combos;
21193 word num_favorite_combo_aliases;
21194 387 word s_version=0;
21195
21196 //section version info
21197
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&s_version,f))
21198 {
21199 return qe_invalid;
21200 }
21201
21202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if (!should_skip)
21203 387 FFCore.quest_format[vFavourites] = s_version;
21204
21205
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
21206 {
21207 return qe_invalid;
21208 }
21209
21210 //section size
21211
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy_dword,f))
21212 {
21213 return qe_invalid;
21214 }
21215
21216 387 word per_row = FAVORITECOMBO_PER_ROW;
21217 387 word per_page = FAVORITECOMBO_PER_PAGE;
21218
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 171 times.
387 if(s_version >= 3)
21219
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 if(!p_igetw(&per_row,f))
21220 return qe_invalid;
21221
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 165 times.
387 if(s_version >= 4)
21222
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_igetw(&per_page,f))
21223 return qe_invalid;
21224 //finally... section data
21225
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&num_favorite_combos,f))
21226 {
21227 return qe_invalid;
21228 }
21229
21230 //Hack; port old favorite combos
21231
3/4
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 216 times.
387 if(s_version < 3 && num_favorite_combos == 100)
21232 216 per_row = 13;
21233
21234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if (!should_skip)
21235
2/2
✓ Branch 0 taken 487620 times.
✓ Branch 1 taken 387 times.
488007 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21236 488007 favorite_combos[q] = -1;
21237 387 byte favtype = 0;
21238
2/2
✓ Branch 0 taken 28048 times.
✓ Branch 1 taken 387 times.
28435 for(int32_t i=0; i<num_favorite_combos; i++)
21239 {
21240
2/2
✓ Branch 0 taken 6442 times.
✓ Branch 1 taken 21606 times.
28048 if (s_version >= 4)
21241 {
21242
1/2
✓ Branch 0 taken 6442 times.
✗ Branch 1 not taken.
6442 if (!p_getc(&favtype, f))
21243 {
21244 return qe_invalid;
21245 }
21246 6442 }
21247 else
21248 21606 favtype = 0;
21249
1/2
✓ Branch 0 taken 28048 times.
✗ Branch 1 not taken.
28048 if(!p_igetl(&temp_num,f))
21250 {
21251 return qe_invalid;
21252 }
21253
21254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28048 times.
28048 if (should_skip)
21255 continue;
21256
21257
2/2
✓ Branch 0 taken 6442 times.
✓ Branch 1 taken 21606 times.
28048 if(per_row == FAVORITECOMBO_PER_ROW)
21258 {
21259 6442 favorite_combos[i] = temp_num;
21260 6442 favorite_combo_modes[i] = favtype;
21261 6442 }
21262 else
21263 {
21264 21606 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21265 21606 favorite_combos[new_i]=temp_num;
21266 21606 favorite_combo_modes[new_i] = favtype;
21267 }
21268 28048 }
21269
21270 // Discard the separate favorite aliases list from previous versions
21271
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 222 times.
387 if(s_version<4)
21272 {
21273
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if (!p_igetw(&num_favorite_combo_aliases, f))
21274 {
21275 return qe_invalid;
21276 }
21277
21278
2/2
✓ Branch 0 taken 21600 times.
✓ Branch 1 taken 222 times.
21822 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21279 {
21280
1/2
✓ Branch 0 taken 21600 times.
✗ Branch 1 not taken.
21600 if (!p_igetl(&temp_num, f))
21281 {
21282 return qe_invalid;
21283 }
21284 21600 }
21285 222 }
21286
21287 387 word max_combo_cols = 0;
21288 387 word max_mappages = 0;
21289
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 171 times.
387 if(s_version >= 2)
21290 {
21291
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 if(!p_igetw(&max_combo_cols,f))
21292 return qe_invalid;
21293 171 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21294
2/2
✓ Branch 0 taken 684 times.
✓ Branch 1 taken 171 times.
855 for(int q = 0; q < max_combo_cols; ++q)
21295 {
21296
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetl(&tmp,f))
21297 return qe_invalid;
21298
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetl(&tmp2,f))
21299 return qe_invalid;
21300
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetl(&tmp3,f))
21301 return qe_invalid;
21302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 684 times.
684 if(q < MAX_COMBO_COLS)
21303 {
21304 684 First[q] = tmp;
21305 684 combo_alistpos[q] = tmp2;
21306 684 combo_pool_listpos[q] = tmp3;
21307 684 }
21308 684 }
21309
21310
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 if(!p_igetw(&max_mappages,f))
21311 return qe_invalid;
21312
2/2
✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 171 times.
1710 for(int q = 0; q < max_mappages; ++q)
21313 {
21314
1/2
✓ Branch 0 taken 1539 times.
✗ Branch 1 not taken.
1539 if(!p_igetl(&tmp,f))
21315 return qe_invalid;
21316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1539 times.
1539 if(!p_igetl(&tmp2,f))
21317 return qe_invalid;
21318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1539 times.
1539 if(q < MAX_MAPPAGE_BTNS)
21319 {
21320 1539 map_page[q].map = tmp;
21321 1539 map_page[q].screen = tmp2;
21322 1539 }
21323 1539 }
21324 171 }
21325
21326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if (should_skip)
21327 return 0;
21328
21329
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 387 times.
1251 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21330 {
21331 864 First[q] = 0;
21332 864 combo_alistpos[q] = 0;
21333 864 combo_pool_listpos[q] = 0;
21334 864 }
21335
2/2
✓ Branch 0 taken 1944 times.
✓ Branch 1 taken 387 times.
2331 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21336 {
21337 1944 map_page[q].map = 0;
21338 1944 map_page[q].screen = 0;
21339 1944 }
21340
21341 387 return 0;
21342 387 }
21343
21344 /*
21345 switch (ret) {
21346 case 0:
21347 break;
21348
21349 case qe_invalid:
21350 goto invalid;
21351 break;
21352 default:
21353 pack_fclose(f);
21354 if(!oldquest)
21355 delete_file(tmpfilename);
21356 return ret;
21357 break;
21358 }
21359 */
21360
21361 const char *skip_text[skip_max]=
21362 {
21363 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21364 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21365 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21366 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21367 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21368 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21369 "skip_favorites"
21370 };
21371
21372
21373 void port250QuestRules(){
21374
21375 portCandleRules(); //Candle
21376 portBombRules();
21377
21378 }
21379
21380 void portCandleRules()
21381 {
21382 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21383 //itemdata itemsbuf;
21384 for ( int32_t q = 0; q < MAXITEMS; q++ )
21385 {
21386 if ( itemsbuf[q].family == itype_candle )
21387 {
21388 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21389 else itemsbuf[q].flags &= ~ item_flag2;
21390 }
21391 }
21392 }
21393
21394 void portBombRules()
21395 {
21396 bool hurtshero = get_qr(qr_OUCHBOMBS);
21397 //itemdata itemsbuf;
21398 for ( int32_t q = 0; q < MAXITEMS; q++ )
21399 {
21400 if ( itemsbuf[q].family == itype_bomb )
21401 {
21402 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21403 else itemsbuf[q].flags &= ~ item_flag2;
21404 }
21405 }
21406 }
21407
21408 18189 static int section_id_to_enum(int id)
21409 {
21410
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 787 times.
✓ Branch 3 taken 787 times.
✓ Branch 4 taken 787 times.
✓ Branch 5 taken 787 times.
✓ Branch 6 taken 704 times.
✓ Branch 7 taken 787 times.
✓ Branch 8 taken 787 times.
✓ Branch 9 taken 787 times.
✓ Branch 10 taken 787 times.
✓ Branch 11 taken 787 times.
✓ Branch 12 taken 787 times.
✓ Branch 13 taken 704 times.
✓ Branch 14 taken 704 times.
✓ Branch 15 taken 787 times.
✓ Branch 16 taken 787 times.
✓ Branch 17 taken 728 times.
✓ Branch 18 taken 704 times.
✓ Branch 19 taken 704 times.
✓ Branch 20 taken 704 times.
✓ Branch 21 taken 787 times.
✓ Branch 22 taken 787 times.
✓ Branch 23 taken 728 times.
✓ Branch 24 taken 704 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
18189 switch (id)
21411 {
21412 case ID_HEADER: return skip_header;
21413 787 case ID_RULES: return skip_rules;
21414 787 case ID_STRINGS: return skip_strings;
21415 787 case ID_MISC: return skip_misc;
21416 787 case ID_TILES: return skip_tiles;
21417 787 case ID_COMBOS: return skip_combos;
21418 704 case ID_COMBOALIASES: return skip_comboaliases;
21419 787 case ID_CSETS: return skip_csets;
21420 787 case ID_MAPS: return skip_maps;
21421 787 case ID_DMAPS: return skip_dmaps;
21422 787 case ID_DOORS: return skip_doors;
21423 787 case ID_ITEMS: return skip_items;
21424 787 case ID_WEAPONS: return skip_weapons;
21425 704 case ID_COLORS: return skip_colors;
21426 704 case ID_ICONS: return skip_icons;
21427 787 case ID_INITDATA: return skip_initdata;
21428 787 case ID_GUYS: return skip_guys;
21429 728 case ID_HEROSPRITES: return skip_herosprites;
21430 704 case ID_SUBSCREEN: return skip_subscreens;
21431 704 case ID_FFSCRIPT: return skip_ffscript;
21432 704 case ID_SFX: return skip_sfx;
21433 787 case ID_MIDIS: return skip_midis;
21434 787 case ID_CHEATS: return skip_cheats;
21435 728 case ID_ITEMDROPSETS: return skip_itemdropsets;
21436 704 case ID_FAVORITES: return skip_favorites;
21437 case ID_ZINFO: return skip_zinfo;
21438 }
21439
21440 return -1;
21441 18189 }
21442
21443 17781 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21444 {
21445 17781 int section_enum = section_id_to_enum(section_id);
21446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17781 times.
17781 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21447
2/2
✓ Branch 0 taken 6657 times.
✓ Branch 1 taken 11124 times.
17781 if (skip)
21448 {
21449 word s_version;
21450
1/2
✓ Branch 0 taken 6657 times.
✗ Branch 1 not taken.
6657 if (!p_igetw(&s_version,f))
21451 {
21452 return qe_invalid;
21453 }
21454
21455
1/2
✓ Branch 0 taken 6657 times.
✗ Branch 1 not taken.
6657 if (!read_deprecated_section_cversion(f))
21456 {
21457 return qe_invalid;
21458 }
21459
21460
3/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6340 times.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
6657 if (section_id == ID_RULES && s_version > 16)
21461 {
21462 dword dummy;
21463 if (!p_igetl(&dummy,f))
21464 {
21465 return qe_invalid;
21466 }
21467 }
21468
21469
3/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6340 times.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
6657 if (section_id == ID_FFSCRIPT && s_version >= 18)
21470 {
21471 word dummy;
21472 if (!p_igetw(&dummy,f))
21473 {
21474 return qe_invalid;
21475 }
21476 }
21477
21478 dword section_length;
21479
1/2
✓ Branch 0 taken 6657 times.
✗ Branch 1 not taken.
6657 if (!p_igetl(&section_length,f))
21480 {
21481 return qe_invalid;
21482 }
21483
21484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6657 times.
6657 if (pack_fseek(f, section_length))
21485 {
21486 return qe_invalid;
21487 }
21488
21489
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6340 times.
6657 if (!pack_feof(f))
21490 {
21491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6340 times.
6340 if (!p_mgetl(&section_id,f))
21492 {
21493 return qe_invalid;
21494 }
21495 6340 }
21496
21497 6657 return qe_cancel;
21498 }
21499
21500 11124 return qe_OK;
21501 17781 }
21502
21503 // TODO: this was copied from zc/zasm_utils.cpp
21504 288 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
21505 {
21506 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
21507
21508 288 std::vector<zasm_script*> scripts;
21509
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 scripts.reserve(zasm_scripts.size());
21510
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 311361 times.
311649 for (auto& script : zasm_scripts)
21511
3/4
✓ Branch 0 taken 311361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8817 times.
✓ Branch 3 taken 302544 times.
311361 if (script->valid())
21512
1/2
✓ Branch 0 taken 8817 times.
✗ Branch 1 not taken.
8817 scripts.push_back(script.get());
21513
21514
2/4
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
288 std::for_each(scripts.begin(), scripts.end(), fn);
21515 288 }
21516
21517 469 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
21518 {
21519 // 2.55.9 or newer?
21520
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 331 times.
469 if (header.compareVer(2, 55, 9) >= 0)
21521 138 return false; // defer to whatever was set
21522
21523 // Replays created in 2.55 for quests prior to 2.55.9 should continue hiding the bottom pixels.
21524
12/18
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 281 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 281 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 281 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 281 times.
✓ Branch 10 taken 50 times.
✓ Branch 11 taken 281 times.
✓ Branch 12 taken 37 times.
✓ Branch 13 taken 294 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
331 if (replay_is_replaying() && replay_get_meta_str("zc_version_created").starts_with("2.55"))
21525 37 return true;
21526
21527 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
21528
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 std::string title = header.title;
21529
3/4
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 291 times.
✓ Branch 3 taken 3 times.
294 if (title == "Stellar Seas")
21530 3 return false;
21531
3/4
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 288 times.
291 if (title == "Yuurand: Tales of the Labyrinth")
21532 3 return true;
21533
21534 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
21535 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
21536 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
21537 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
21538 288 bool found = false;
21539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
9105 _zasm_for_every_script([&](auto script){
21540
2/2
✓ Branch 0 taken 3034 times.
✓ Branch 1 taken 5783 times.
8817 if (found) return;
21541
21542
2/2
✓ Branch 0 taken 5751 times.
✓ Branch 1 taken 25292920 times.
25298671 for (const auto& instr : script->zasm)
21543 {
21544
4/4
✓ Branch 0 taken 22146115 times.
✓ Branch 1 taken 3146805 times.
✓ Branch 2 taken 367522 times.
✓ Branch 3 taken 21778593 times.
25292920 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
21545
21546 3514327 int value = instr.arg2;
21547
9/10
✓ Branch 0 taken 3514324 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3514320 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 3514296 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3514296 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 3514295 times.
3514327 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
21548 {
21549 32 found = true;
21550 32 break;
21551 }
21552 }
21553 8817 });
21554
21555 288 return found;
21556 469 }
21557
21558 //Internal function for loadquest wrapper
21559 787 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21560 {
21561 787 DMapEditorLastMaptileUsed = 0;
21562 787 combosread=false;
21563 787 mapsread=false;
21564 787 fixffcs=false;
21565
21566 787 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21567
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21568 {
21569 set_bit(skip_flags, skip_ffscript, 1);
21570 setZScriptVersion(V_FFSCRIPT);
21571 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21572 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21573 do_clear_scripts = true;
21574 }
21575
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(loading_tileset_flags & TILESET_CLEARMAPS)
21576 {
21577 set_bit(skip_flags, skip_maps, 1);
21578 }
21579
21580 // show_progress=true;
21581 char tmpfilename[L_tmpnam];
21582 787 temp_name(tmpfilename);
21583 // char percent_done[30];
21584 787 bool catchup=false;
21585 byte tempbyte;
21586 787 word old_map_count=map_count;
21587
21588 787 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21589 787 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21590 787 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21591
21592
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 318 times.
787 if(get_bit(skip_flags, skip_rules))
21593 {
21594 318 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21595 318 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21596 318 }
21597
21598 787 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21599 787 unpack_qrs();
21600 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21601
21602
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 318 times.
787 if(get_bit(skip_flags, skip_midis))
21603 {
21604 318 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21605 318 }
21606
21607
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 318 times.
787 if (!get_bit(skip_flags, skip_maps))
21608 469 Regions = {};
21609
21610
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 469 times.
787 if(do_clear_scripts)
21611 {
21612 469 zScript.clear();
21613 469 globalmap.clear();
21614 469 genericmap.clear();
21615 469 ffcmap.clear();
21616 469 itemmap.clear();
21617 469 npcmap.clear();
21618 469 ewpnmap.clear();
21619 469 lwpnmap.clear();
21620 469 playermap.clear();
21621 469 dmapmap.clear();
21622 469 screenmap.clear();
21623 469 itemspritemap.clear();
21624 469 comboscriptmap.clear();
21625 469 subscreenmap.clear();
21626
21627
2/2
✓ Branch 0 taken 239659 times.
✓ Branch 1 taken 469 times.
240128 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21628 {
21629 239659 ffcmap[i].clear();
21630 239659 }
21631
21632 469 globalmap[0].slotname = "Slot 1:";
21633 469 globalmap[0].scriptname = "~Init";
21634 469 globalmap[0].update();
21635
21636
2/2
✓ Branch 0 taken 3283 times.
✓ Branch 1 taken 469 times.
3752 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21637 {
21638 3283 globalmap[i].clear();
21639 3283 }
21640
21641
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21642 {
21643 119595 itemmap[i].clear();
21644 119595 }
21645
21646 //new script types -- prevent carrying over to a quest that you load after reading them
21647 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21648
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21649 {
21650 119595 npcmap[i].clear();
21651 119595 }
21652
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21653 {
21654 119595 lwpnmap[i].clear();
21655 119595 }
21656
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21657 {
21658 119595 ewpnmap[i].clear();
21659 119595 }
21660
2/2
✓ Branch 0 taken 1876 times.
✓ Branch 1 taken 469 times.
2345 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
21661 {
21662 1876 playermap[i].clear();
21663 1876 }
21664
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21665 {
21666 119595 dmapmap[i].clear();
21667 119595 }
21668
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21669 {
21670 119595 screenmap[i].clear();
21671 119595 }
21672
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21673 {
21674 119595 itemspritemap[i].clear();
21675 119595 }
21676
2/2
✓ Branch 0 taken 239659 times.
✓ Branch 1 taken 469 times.
240128 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21677 {
21678 239659 comboscriptmap[i].clear();
21679 239659 }
21680
2/2
✓ Branch 0 taken 239659 times.
✓ Branch 1 taken 469 times.
240128 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21681 {
21682 239659 genericmap[i].clear();
21683 239659 }
21684
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21685 {
21686 119595 subscreenmap[i].clear();
21687 119595 }
21688
21689 469 reset_scripts();
21690 469 }
21691
21692 787 zquestheader tempheader{};
21693
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 tempheader.filename = filename;
21694
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 zinfo tempzi;
21695
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 tempzi.clear();
21696 787 load_tmp_zi = &tempzi;
21697
21698 // oldquest flag is set when an unencrypted qst file is suspected.
21699 787 bool oldquest = false;
21700 787 int32_t open_error=0;
21701
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21702
21703
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if (!f)
21704 {
21705 ASSERT(open_error != 0);
21706 return open_error;
21707 }
21708 char zinfofilename[2048];
21709
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 replace_extension(zinfofilename, filename, "zinfo", 2047);
21710 787 int32_t ret=0;
21711
21712 //header
21713
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_out("Reading Header...");
21714
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 ret=readheader(f, &tempheader, printmetadata);
21715
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
787 checkstatus(ret);
21716
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_out("okay.");
21717
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_eol();
21718
21719
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 605 times.
787 if(read_zinfo)
21720 {
21721
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 box_out("Reading ZInfo - ");
21722
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 box_out(read_ext_zinfo ? "External..." : "Internal...");
21723
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 179 times.
182 if(read_ext_zinfo)
21724 {
21725
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21726
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
21727
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
21728
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
21729 3 }
21730 else
21731 {
21732
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 ret=readzinfo(f, tempzi, tempheader);
21733
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
179 checkstatus(ret);
21734 }
21735
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 box_out("okay.");
21736
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 box_eol();
21737 182 }
21738
21739
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 24 times.
787 if(tempheader.zelda_version>=0x193)
21740 {
21741 dword section_id;
21742
21743 //section id
21744
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_mgetl(&section_id,f))
21745 {
21746 goto invalid;
21747 }
21748
21749 763 std::set<dword> seen_sections;
21750
21751
3/4
✓ Branch 0 taken 18544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17781 times.
✓ Branch 3 taken 763 times.
18544 while(!pack_feof(f))
21752 {
21753
2/4
✓ Branch 0 taken 17781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17781 times.
✗ Branch 3 not taken.
17781 if (seen_sections.contains(section_id))
21754 goto invalid;
21755
1/2
✓ Branch 0 taken 17781 times.
✗ Branch 1 not taken.
17781 seen_sections.insert(section_id);
21756
21757
3/4
✓ Branch 0 taken 17781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11124 times.
✓ Branch 3 taken 6657 times.
17781 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21758 {
21759
1/2
✓ Branch 0 taken 6657 times.
✗ Branch 1 not taken.
6657 if (retval == qe_cancel)
21760 6657 continue;
21761 checkstatus(retval);
21762 }
21763
21764
24/25
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 446 times.
✓ Branch 2 taken 763 times.
✓ Branch 3 taken 763 times.
✓ Branch 4 taken 446 times.
✓ Branch 5 taken 387 times.
✓ Branch 6 taken 763 times.
✓ Branch 7 taken 446 times.
✓ Branch 8 taken 446 times.
✓ Branch 9 taken 446 times.
✓ Branch 10 taken 446 times.
✓ Branch 11 taken 446 times.
✓ Branch 12 taken 387 times.
✓ Branch 13 taken 387 times.
✓ Branch 14 taken 446 times.
✓ Branch 15 taken 446 times.
✓ Branch 16 taken 387 times.
✓ Branch 17 taken 387 times.
✓ Branch 18 taken 387 times.
✓ Branch 19 taken 387 times.
✓ Branch 20 taken 446 times.
✓ Branch 21 taken 446 times.
✓ Branch 22 taken 387 times.
✓ Branch 23 taken 387 times.
✗ Branch 24 not taken.
11124 switch(section_id)
21765 {
21766 case ID_RULES:
21767
21768 //rules
21769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21770 {
21771 box_out("found.");
21772 box_eol();
21773 catchup=false;
21774 }
21775
21776
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Rules...");
21777
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readrules(f, &tempheader);
21778
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21779
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21780
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21781 446 break;
21782
21783 case ID_STRINGS:
21784
21785 //strings
21786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21787 {
21788 box_out("found.");
21789 box_eol();
21790 catchup=false;
21791 }
21792
21793
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Strings...");
21794
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readstrings(f, &tempheader);
21795
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21796
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21797
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21798 446 break;
21799
21800 case ID_MISC:
21801
21802 //misc data
21803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if(catchup)
21804 {
21805 box_out("found.");
21806 box_eol();
21807 catchup=false;
21808 }
21809
21810
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("Reading Misc. Data...");
21811
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 ret=readmisc(f, &tempheader, Misc);
21812
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
763 checkstatus(ret);
21813
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("okay.");
21814
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_eol();
21815 763 break;
21816
21817 case ID_TILES:
21818
21819 //tiles
21820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if(catchup)
21821 {
21822 box_out("found.");
21823 box_eol();
21824 catchup=false;
21825 }
21826
21827
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("Reading Tiles...");
21828
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21829
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
763 checkstatus(ret);
21830
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("okay.");
21831
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_eol();
21832 763 break;
21833
21834 case ID_COMBOS:
21835
21836 //combos
21837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21838 {
21839 box_out("found.");
21840 box_eol();
21841 catchup=false;
21842 }
21843
21844
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Combos...");
21845
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21846 446 combosread=true;
21847
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21848
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21849
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21850 446 break;
21851
21852 case ID_COMBOALIASES:
21853
21854 //combo aliases
21855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
21856 {
21857 box_out("found.");
21858 box_eol();
21859 catchup=false;
21860 }
21861
21862
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Combo Aliases...");
21863
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21864
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
21865
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
21866
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
21867 387 break;
21868
21869 case ID_CSETS:
21870
21871 //color data
21872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if(catchup)
21873 {
21874 box_out("found.");
21875 box_eol();
21876 catchup=false;
21877 }
21878
21879
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("Reading Color Data...");
21880
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21881
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
763 checkstatus(ret);
21882
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("okay.");
21883
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_eol();
21884 763 break;
21885
21886 case ID_MAPS:
21887
21888 //maps
21889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21890 {
21891 box_out("found.");
21892 box_eol();
21893 catchup=false;
21894 }
21895
21896
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Maps...");
21897
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readmaps(f, &tempheader);
21898 446 mapsread=true;
21899
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21900
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21901
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21902 446 break;
21903
21904 case ID_DMAPS:
21905
21906 //dmaps
21907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21908 {
21909 box_out("found.");
21910 box_eol();
21911 catchup=false;
21912 }
21913
21914
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading DMaps...");
21915
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21916
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21917
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21918
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21919 446 break;
21920
21921 case ID_DOORS:
21922
21923 //door combo sets
21924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21925 {
21926 box_out("found.");
21927 box_eol();
21928 catchup=false;
21929 }
21930
21931
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Doors...");
21932
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readdoorcombosets(f, &tempheader);
21933
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21934
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21935
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21936 446 break;
21937
21938 case ID_ITEMS:
21939
21940 //items
21941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21942 {
21943 box_out("found.");
21944 box_eol();
21945 catchup=false;
21946 }
21947
21948
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Items...");
21949
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21950
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21951
21952
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21953
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21954 446 break;
21955
21956 case ID_WEAPONS:
21957
21958 //weapons
21959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21960 {
21961 box_out("found.");
21962 box_eol();
21963 catchup=false;
21964 }
21965
21966
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Weapons...");
21967
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readweapons(f, &tempheader);
21968
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21969
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21970
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21971 446 break;
21972
21973 case ID_COLORS:
21974
21975 //misc. colors
21976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
21977 {
21978 box_out("found.");
21979 box_eol();
21980 catchup=false;
21981 }
21982
21983
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Misc. Colors...");
21984
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readmisccolors(f, &tempheader, Misc);
21985
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
21986
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
21987
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
21988 387 break;
21989
21990 case ID_ICONS:
21991
21992 //game icons
21993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
21994 {
21995 box_out("found.");
21996 box_eol();
21997 catchup=false;
21998 }
21999
22000
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Game Icons...");
22001
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readgameicons(f, &tempheader, Misc);
22002
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22003
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22004
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22005 387 break;
22006
22007 case ID_INITDATA:
22008
22009 //initialization data
22010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
22011 {
22012 box_out("found.");
22013 box_eol();
22014 catchup=false;
22015 }
22016
22017
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Init. Data...");
22018
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readinitdata(f, &tempheader);
22019
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
22020
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
22021
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
22022
22023
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
446 if(!get_bit(skip_flags, skip_subscreens))
22024 {
22025
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 353 times.
446 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22026 {
22027
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 setupsubscreens();
22028
22029
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 93 times.
47709 for(int32_t i=0; i<MAXDMAPS; ++i)
22030 {
22031 47616 int32_t type=DMaps[i].type&dmfTYPE;
22032
2/2
✓ Branch 0 taken 1085 times.
✓ Branch 1 taken 46531 times.
47616 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22033 47616 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22034 47616 }
22035 93 }
22036 446 }
22037
22038
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!get_bit(skip_flags, skip_sfx))
22039 {
22040 446 setupsfx();
22041 446 }
22042
22043
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!get_bit(skip_flags, skip_itemdropsets))
22044 {
22045
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 init_item_drop_sets();
22046 446 }
22047
22048
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
446 if(!get_bit(skip_flags, skip_favorites))
22049 {
22050 446 init_favorites();
22051 446 }
22052
22053 446 break;
22054
22055 case ID_GUYS:
22056
22057 //guys
22058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
22059 {
22060 box_out("found.");
22061 box_eol();
22062 catchup=false;
22063 }
22064
22065
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Custom Guy Data...");
22066
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readguys(f, &tempheader);
22067
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
22068
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
22069
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
22070 446 break;
22071
22072 case ID_HEROSPRITES:
22073
22074 //hero sprites
22075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22076 {
22077 box_out("found.");
22078 box_eol();
22079 catchup=false;
22080 }
22081
22082
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Custom Hero Sprite Data...");
22083
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readherosprites(f, &tempheader);
22084
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22085
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22086
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22087 387 break;
22088
22089 case ID_SUBSCREEN:
22090
22091 //custom subscreens
22092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22093 {
22094 box_out("found.");
22095 box_eol();
22096 catchup=false;
22097 }
22098
22099
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Custom Subscreen Data...");
22100
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readsubscreens(f);
22101
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22102
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22103
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22104 387 break;
22105
22106 case ID_FFSCRIPT:
22107
22108 //Freeform combo scripts
22109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22110 {
22111 box_out("found.");
22112 box_eol();
22113 catchup=false;
22114 }
22115
22116
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading FF Script Data...");
22117
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readffscript(f, &tempheader);
22118
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22119
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22120
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22121 387 break;
22122
22123 case ID_SFX:
22124
22125 //SFX data
22126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22127 {
22128 box_out("found.");
22129 box_eol();
22130 catchup=false;
22131 }
22132
22133
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading SFX Data...");
22134
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readsfx(f, &tempheader);
22135
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22136
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22137
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22138 387 break;
22139
22140 case ID_MIDIS:
22141
22142 //midis
22143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
22144 {
22145 box_out("found.");
22146 box_eol();
22147 catchup=false;
22148 }
22149
22150
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Tunes...");
22151
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readtunes(f, &tempheader, tunes);
22152
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
22153
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
22154
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
22155 446 break;
22156
22157 case ID_CHEATS:
22158
22159 //cheat codes
22160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
22161 {
22162 box_out("found.");
22163 box_eol();
22164 catchup=false;
22165 }
22166
22167
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Cheat Codes...");
22168
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readcheatcodes(f, &tempheader);
22169
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
22170
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
22171
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
22172 446 break;
22173
22174 case ID_ITEMDROPSETS:
22175
22176 //item drop sets
22177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22178 {
22179 box_out("found.");
22180 box_eol();
22181 catchup=false;
22182 }
22183
22184
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Item Drop Sets...");
22185
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readitemdropsets(f, tempheader.zelda_version);
22186
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22187
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22188
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22189 387 break;
22190
22191 case ID_FAVORITES:
22192
22193 //favorite combos and combo aliases
22194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22195 {
22196 box_out("found.");
22197 box_eol();
22198 catchup=false;
22199 }
22200
22201
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Favorite Combos...");
22202
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readfavorites(f, tempheader.zelda_version);
22203
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22204
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22205
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22206 387 break;
22207
22208 default:
22209 if(!catchup)
22210 {
22211 box_out("Bad token! Searching...");
22212 box_eol();
22213 }
22214
22215 catchup=true;
22216 break;
22217 }
22218
22219
22220
1/2
✓ Branch 0 taken 11124 times.
✗ Branch 1 not taken.
11124 if(catchup)
22221 {
22222 //section id
22223 section_id=(section_id<<8);
22224
22225 if(!p_getc(&tempbyte,f))
22226 {
22227 goto invalid;
22228 }
22229
22230 section_id+=tempbyte;
22231 }
22232
22233 else
22234 {
22235 //section id
22236
3/4
✓ Branch 0 taken 11124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10678 times.
✓ Branch 3 taken 446 times.
11124 if(!pack_feof(f))
22237 {
22238
2/4
✓ Branch 0 taken 10678 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10678 times.
✗ Branch 3 not taken.
10678 if(!p_mgetl(&section_id,f))
22239 {
22240 goto invalid;
22241 }
22242 10678 }
22243 }
22244 }
22245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 }
22246 else
22247 {
22248
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22249
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22250
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22251
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22252
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22253
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22254
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22255
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22256
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22257
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22258
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22259
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22260
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22261
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22262
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22263
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22264
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22265
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22266 };
22267
22268 24 legacy_skip_flags = skip_flags;
22269
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22270 {
22271
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22272
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22273
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22274 {
22275 // Nothing to read.
22276
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22277 1 continue;
22278
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22279 1 continue;
22280
22281 // Haven't looked at how to skip these, because we don't need to currently: the only
22282 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22283
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22284 1 continue;
22285
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22286 1 continue;
22287
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22288 1 continue;
22289
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22290 1 continue;
22291
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22292 1 continue;
22293 9 }
22294
22295 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22296 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22297 // read all the sections even if requested to skip some.
22298 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22299 // {
22300 // if (retval == qe_cancel)
22301 // continue;
22302 // checkstatus(retval);
22303 // }
22304
22305
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22306
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22307
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22308
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22309
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22310 }
22311 24 legacy_skip_flags = nullptr;
22312
22313
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22314 {
22315
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22316
22317
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22318 {
22319 11776 int32_t type=DMaps[i].type&dmfTYPE;
22320
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22321 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22322 11776 }
22323 23 }
22324
22325
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22326
22327
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22328 23 setupsfx();
22329
22330
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22331 23 init_favorites();
22332
22333
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22334
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22335
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22336
22337
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 init_spritelists();
22338
22339 // check data
22340
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(f)
22341 {
22342
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 pack_fclose(f);
22343 787 }
22344
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 clear_quest_tmpfile();
22345
22346
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(!oldquest)
22347 {
22348
2/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 787 times.
787 if(exists(tmpfilename))
22349 {
22350 delete_file(tmpfilename);
22351 }
22352 787 }
22353
22354
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
787 if(fixffcs && combosread && mapsread)
22355 {
22356 for(int32_t i=0; i<map_count; i++)
22357 {
22358 for(int32_t j=0; j<MAPSCRS; j++)
22359 {
22360 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
22361 for(int32_t m=0; m<c; m++)
22362 {
22363 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22364 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22365 }
22366 }
22367 }
22368 }
22369
22370
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 318 times.
787 if (!get_bit(skip_flags, skip_rules))
22371 {
22372
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
22373
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
22374
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 397 times.
469 if (should_hide)
22375
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
22376
22377
3/4
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 350 times.
469 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
22378 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
22379 469 }
22380
22381
7/10
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 723 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 63 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 63 times.
✗ Branch 9 not taken.
787 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22382 {
22383
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_CONTFULL_DEP, 0);
22384
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22385 63 zinit.cont_heart=100;
22386 63 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22387 63 }
22388
22389
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_out("Done.");
22390
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_eol();
22391
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_end(false);
22392
22393
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 470 times.
✓ Branch 3 taken 317 times.
787 if(!get_bit(skip_flags, skip_header))
22394 {
22395
1/2
✓ Branch 0 taken 470 times.
✗ Branch 1 not taken.
470 *Header = tempheader;
22396 470 }
22397
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 318 times.
787 if(!get_bit(skip_flags, skip_zinfo))
22398 {
22399
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ZI.copyFrom(tempzi);
22400 469 }
22401
22402
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 318 times.
787 if(get_bit(skip_flags, skip_maps))
22403 {
22404 318 map_count=old_map_count;
22405 318 }
22406
22407
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 318 times.
✓ Branch 3 taken 469 times.
787 if(get_bit(skip_flags, skip_rules))
22408 {
22409 318 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22410 318 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22411
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 unpack_qrs();
22412 318 }
22413
22414
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 318 times.
✓ Branch 3 taken 469 times.
787 if(get_bit(skip_flags, skip_midis))
22415 {
22416 318 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22417 318 }
22418
22419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if(loading_tileset_flags & TILESET_CLEARMAPS)
22420 {
22421 TheMaps.clear();
22422 TheMaps.resize(MAPSCRS*1);
22423 map_count = 1;
22424 map_autolayers.clear();
22425 map_autolayers.resize(6*1);
22426 }
22427
22428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if(loading_tileset_flags & TILESET_CLEARHEADER)
22429 {
22430 memset(Header->password, 0, sizeof(Header->password));
22431 memset(Header->minver, 0, sizeof(Header->minver));
22432 memset(Header->title, 0, sizeof(Header->title));
22433 memset(Header->author, 0, sizeof(Header->author));
22434 memset(Header->version, 0, sizeof(Header->version));
22435 Header->use_keyfile = 0;
22436 Header->dirty_password = false;
22437 cvs_MD5Context ctx;
22438 cvs_MD5Init(&ctx);
22439 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22440 cvs_MD5Final(Header->pwd_hash, &ctx);
22441 }
22442
22443
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 318 times.
787 if (!get_bit(skip_flags, skip_maps))
22444 {
22445 // Not needed, so release its memory.
22446
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 old_combo_pages = {};
22447 469 }
22448
22449 787 return qe_OK;
22450
22451 invalid:
22452 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22453 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22454 box_out("error.");
22455 box_eol();
22456 box_end(true);
22457
22458 pack_fclose(f);
22459
22460 if(!oldquest)
22461 {
22462 if(exists(tmpfilename))
22463 {
22464 delete_file(tmpfilename);
22465 }
22466 }
22467
22468 return qe_invalid;
22469
22470 787 }
22471
22472 static bool _is_loading_quest;
22473
22474 bool is_loading_quest()
22475 {
22476 return _is_loading_quest;
22477 }
22478
22479 317 std::string get_last_loaded_qstpath()
22480 {
22481 317 return last_loaded_qstpath;
22482 }
22483
22484 787 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22485 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22486 bool report, byte qst_num, dword tilesetflags)
22487 {
22488 787 loading_tileset_flags = tilesetflags;
22489 787 const char* basename = get_filename(filename);
22490 787 zapp_reporting_add_breadcrumb("load_quest", basename);
22491 787 zapp_reporting_set_tag("qst.filename", basename);
22492
22493 787 last_loaded_qstpath = filename;
22494 787 loading_qst_name = filename;
22495 787 loading_qst_num = qst_num;
22496 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22497 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22498
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if (!is_ci())
22499 loadquest_report = report;
22500
22501 787 _is_loading_quest = true;
22502 787 auto start = std::chrono::steady_clock::now();
22503 787 zprint2("Loading qst: %s\n", filename);
22504 787 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22505 787 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22506 787 zprint2("Time to load qst: %d ms\n", load_ms);
22507 787 _is_loading_quest = false;
22508
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if (ret)
22509 zprint2("Error: %s\n", qst_error[ret]);
22510
22511
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(show_progress)
22512 {
22513 if(ret)
22514 {
22515 box_out("-- Error loading quest file! --");
22516 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
22517 box_end(true);
22518 }
22519 else box_end(false);
22520 }
22521
22522 787 load_tmp_zi = NULL;
22523 787 loading_qst_name = NULL;
22524 787 loadquest_report = false;
22525 787 loading_qst_num = 0;
22526
22527 787 zapp_reporting_set_tag("qst.author", Header->author);
22528 787 zapp_reporting_set_tag("qst.title", Header->title);
22529 787 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22530
22531 787 return ret;
22532 }
22533